T
- The type of the response to the event. If the event does not require a response, this should be Void
.public abstract class PluginEvent<T> extends ActionEvent
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 ActionEvent.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 ActionEvent.consume()
, so you do not need
to call both of these methods.
ActionEvent.Type
Constructor and Description |
---|
PluginEvent(Object source,
ActionEvent.Type type)
Creates a new plugin event with the given source and type.
|
Modifier and Type | Method and Description |
---|---|
T |
getPluginEventResponse()
Gets the response to the event.
|
void |
setPluginEventResponse(T response)
Sets the return value of processing the event.
|
consume, getActualComponent, getCommand, getComponent, getDraggedComponent, getDropTarget, getEventType, getKeyEvent, getProgress, getSource, getX, getY, isConsumed, isLongEvent, isPointerPressedDuringDrag, setPointerPressedDuringDrag
public PluginEvent(Object source, ActionEvent.Type type)
source
- The source of the event. May be null.type
- The type of the event. All PluginEvent classes should have a corresponding enum type in the
Type
enum.public void setPluginEventResponse(T response)
ActionEvent.consume()
, so you don't need to
call both to consume the event and set the response.response
- public T getPluginEventResponse()