# Class MessageEvent

java.lang.Object
com.codename1.ui.events.ActionEvent
com.codename1.ui.events.MessageEvent

public class MessageEvent extends ActionEvent
Encapsulates an event that either originates outside the App (e.g. from the webpage that contains the app if it is published using the Javascript port); or whose destination is outside the app.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `MessageEvent.PromptPromise`
  Encapsulates a promise that should be fulfilled when implementingn a custom permissions prompt to record or play audio.

  ### Nested classes/interfaces inherited from class ActionEvent

  `ActionEvent.Type`
  Modifier and Type
  Class
  Description
  `static enum`
  `ActionEvent.Type`
  The event type, as declared when the event is created.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MessageEvent(Object source, String message, int code)`
  Creates a new message.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getCode()`
  Gets the message code.
  `String`
  `getMessage()`
  Gets the message content.
  `MessageEvent.PromptPromise`
  `getPromptPromise()`
  This obtains the "promise" that should be fulfilled if implementing a custom permissions prompt for playing or recording audio.
  `boolean`
  `isPromptForAudioPlayer()`
  Checks to see if this message is a prompt to play audio.
  `boolean`
  `isPromptForAudioRecorder()`
  Checks to see if this message is a prompt to record audio.

  ### Methods inherited from class ActionEvent

  `consume, getActualComponent, getCommand, getComponent, getDraggedComponent, getDropTarget, getEventType, getKeyEvent, getProgress, getSource, getX, getY, isConsumed, isLongEvent, isPointerPressedDuringDrag, setPointerPressedDuringDrag`
  Modifier and Type
  Method
  Description
  `void`
  `consume()`
  Consume the event indicating that it was handled thus preventing other action listeners from handling/receiving the event
  `Component`
  `getActualComponent()`
  Identical to `ActionEvent#getComponent()` except for the fact that a lead component will be returned if such a lead component is available.
  `Command`
  `getCommand()`
  If this event was sent as a result of a command action this method returns that command
  `Component`
  `getComponent()`
  Returns the component that generated the event.
  `Component`
  `getDraggedComponent()`
  Set in the case of a drop listener, returns the component being dragged
  `Component`
  `getDropTarget()`
  Set in the case of a drop listener, returns the component on which the drop occurs
  `ActionEvent.Type`
  `getEventType()`
  Returns the type of the given event allowing us to have more generic event handling code and useful for debugging
  `int`
  `getKeyEvent()`
  If this event was triggered by a key press this method will return the appropriate keycode
  `int`
  `getProgress()`
  Returns the numeric progress of native browser loading on Android
  `Object`
  `getSource()`
  The element that triggered the action event, useful for decoupling event handling code
  `int`
  `getX()`
  The X position if this is a pointer event otherwise undefined
  `int`
  `getY()`
  The Y position if this is a pointer event otherwise undefined
  `boolean`
  `isConsumed()`
  Returns true if the event was consumed thus indicating that it was handled.
  `boolean`
  `isLongEvent()`
  Returns true for long click or long pointer event
  `boolean`
  `isPointerPressedDuringDrag()`
  Only used for pointer dragged events.
  `void`
  `setPointerPressedDuringDrag(boolean pressed)`
  Only used for pointer dragged events.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## Constructor Details

  - ### MessageEvent

    public MessageEvent(Object source, String message, int code)

    Creates a new message.

    ###### Parameters

    - `source`: The source of the message.

    - `message`: The message content.

    - `code`: A code for the message.

- ## Method Details

  - ### getMessage

    public String getMessage()

    Gets the message content.

    ###### Returns

    The message

  - ### getCode

    public int getCode()
    Gets the message code.

  - ### isPromptForAudioRecorder

    public boolean isPromptForAudioRecorder()

    Checks to see if this message is a prompt to record audio. This is currently only used in the Javascript port, and it allows you to implement a custom permissions prompt to record audio.

    See Displaying Custom Prompt to Play Audio for an example.

    ###### Returns

    True if this message is a prompt for the audio recorder.

  - ### isPromptForAudioPlayer

    public boolean isPromptForAudioPlayer()

    Checks to see if this message is a prompt to play audio. This is currently only used in the Javascript port, and it allows you to implement a custom permissions prompt to play audio.

    See Displaying Custom Prompt to Play Audio for an example.

    ###### Returns

    True if this message is a prompt for the audio player.

  - ### getPromptPromise

    public MessageEvent.PromptPromise getPromptPromise()

    This obtains the "promise" that should be fulfilled if implementing a custom permissions prompt for playing or recording audio. Currently this is only used for the Javascript port.

    See Displaying Custom Prompt to Play Audio for an example.

    ###### Returns

    The promise to be fulfilled, or null if this event is not a prompt.

    ###### See also

    - #isPromptForAudioPlayer()

    - #isPromptForAudioRecorder()