# Class PluginEvent<T>

java.lang.Object
com.codename1.ui.events.ActionEvent
com.codename1.plugin.event.PluginEvent<T>

Direct Known Subclasses:
  `IsGalleryTypeSupportedEvent, OpenGalleryEvent`

public abstract class PluginEvent<T> extends ActionEvent

Parent class for all plugin events. Plugin events are fired by the Codename One runtime to give plugins an opportunity to override the implementation of certain core methods.

For example, the `OpenGalleryEvent` is fired when the `Display#openGallery()` method is called. This event will be passed to registered plugins, which can choose to "consume" the event and override the behaviour.

If a plugin wishes to handle the event, it should call `#consume()` on the event to prevent Codename One from proceeding to handle the request itself.

Events that require a synchronous return value should call the `#setPluginEventResponse(Object)` method with the return value. `#setPluginEventResponse(Object)` calls `#consume()`, so you do not need to call both of these methods.

- ## Nested Class Summary

  ### 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
  `PluginEvent(Object source, ActionEvent.Type type)`
  Creates a new plugin event with the given source and type.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `getPluginEventResponse()`
  Gets the response to the event.
  `void`
  `setPluginEventResponse(T response)`
  Sets the return value of processing the event.

  ### 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

  - ### PluginEvent

    public PluginEvent(Object source, ActionEvent.Type type)

    Creates a new plugin event with the given source and type.

    ###### Parameters

    - `source`: The source of the event. May be null.

    - `type`: @param type The type of the event. All PluginEvent classes should have a corresponding enum type in the `Type` enum.

- ## Method Details

  - ### getPluginEventResponse

    public T getPluginEventResponse()

    Gets the response to the event. This will be null if the event has not been consumed.

    ###### Returns

    The result of processing the event.

  - ### setPluginEventResponse

    public void setPluginEventResponse(T response)

    Sets the return value of processing the event. This method calls `#consume()`, so you don't need to call both to consume the event and set the response.

    ###### Parameters

    - `response`