Class ActionEvent
- Direct Known Subclasses:
AsyncMedia.MediaErrorEvent, AsyncMedia.MediaStateChangeEvent, ComponentStateChangeEvent, MessageEvent, NetworkEvent, PluginEvent, WindowEvent
ActionListener callback is invoked-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe event type, as declared when the event is created. -
Constructor Summary
ConstructorsConstructorDescriptionActionEvent(Command source, Component sourceComponent, int x, int y) Creates a new instance of ActionEvent for a commandActionEvent(Command source, ActionEvent.Type type, Component sourceComponent, int x, int y) Creates a new instance of ActionEvent for a commandActionEvent(Component dragged, Component drop, int x, int y) Creates a new instance of ActionEvent for a drop operationActionEvent(Component dragged, ActionEvent.Type type, Component drop, int x, int y) Creates a new instance of ActionEvent for a drop operationActionEvent(Object source) Creates a new instance of ActionEvent.ActionEvent(Object source, int keyEvent) Creates a new instance of ActionEventActionEvent(Object source, int keyEvent, boolean longClick) Creates a new instance of ActionEventActionEvent(Object source, int x, int y) Creates a new instance of ActionEvent as a generic pointer event.ActionEvent(Object source, int x, int y, boolean longPointer) Creates a new instance of ActionEvent as a pointer eventActionEvent(Object source, ActionEvent.Type type) Creates a new instance of ActionEventActionEvent(Object source, ActionEvent.Type type, int keyEvent) Creates a new instance of ActionEvent.ActionEvent(Object source, ActionEvent.Type type, int x, int y) Creates a new instance of ActionEvent as a pointer event -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume()Consume the event indicating that it was handled thus preventing other action listeners from handling/receiving the eventIdentical toActionEvent#getComponent()except for the fact that a lead component will be returned if such a lead component is available.If this event was sent as a result of a command action this method returns that commandReturns the component that generated the event.Set in the case of a drop listener, returns the component being draggedSet in the case of a drop listener, returns the component on which the drop occursReturns the type of the given event allowing us to have more generic event handling code and useful for debuggingintIf this event was triggered by a key press this method will return the appropriate keycodeintReturns the numeric progress of native browser loading on AndroidThe element that triggered the action event, useful for decoupling event handling codeintgetX()The X position if this is a pointer event otherwise undefinedintgetY()The Y position if this is a pointer event otherwise undefinedbooleanReturns true if the event was consumed thus indicating that it was handled.booleanReturns true for long click or long pointer eventbooleanOnly used for pointer dragged events.voidsetPointerPressedDuringDrag(boolean pressed) Only used for pointer dragged events.
-
Constructor Details
-
ActionEvent
Creates a new instance of ActionEvent. This is unused locally, but provided so existing customer code with still work.
Parameters
source: element for the action event
-
ActionEvent
Creates a new instance of ActionEvent
Parameters
-
source: element for the action event -
type: theTypeof the event
-
-
ActionEvent
Creates a new instance of ActionEvent as a pointer event
Parameters
-
source: element for the pointer event -
type: theTypeof the event -
x: (or sometimes width) associated with the event -
y: (or sometimes height)associated with the event
-
-
ActionEvent
Creates a new instance of ActionEvent for a command
Parameters
-
source: element command -
type: theTypeof the event -
sourceComponent: the triggering component -
x: the x position of the pointer event -
y: the y position of the pointer event
-
-
ActionEvent
Creates a new instance of ActionEvent for a drop operation
Parameters
-
dragged: the dragged component -
type: theTypeof the event -
drop: the drop target component -
x: the x position of the pointer event -
y: the y position of the pointer event
-
-
ActionEvent
Creates a new instance of ActionEvent. The key event is really just a numeric code, not indicative of a key press
Parameters
-
source: element for the action event -
type: theTypeof the event -
keyEvent: the key that triggered the event
-
-
ActionEvent
Creates a new instance of ActionEvent
Parameters
-
source: element for the action event -
keyEvent: the key that triggered the event
-
-
ActionEvent
Creates a new instance of ActionEvent
Parameters
-
source: element for the action event -
keyEvent: the key that triggered the event -
longClick: true if the event is triggered from long pressed
-
-
ActionEvent
Creates a new instance of ActionEvent as a pointer event
Parameters
-
source: element for the pointer event -
x: the x position of the pointer event -
y: the y position of the pointer event -
longPointer: true if the event is triggered from long pressed
-
-
ActionEvent
Creates a new instance of ActionEvent as a generic pointer event.
Parameters
-
source: element for the pointer event -
x: the x position of the pointer event -
y: the y position of the pointer event
-
-
ActionEvent
-
ActionEvent
-
-
Method Details
-
getEventType
Returns the type of the given event allowing us to have more generic event handling code and useful for debugging
Returns
the Type enum
-
getSource
The element that triggered the action event, useful for decoupling event handling code
Returns
the element that triggered the action event
-
getKeyEvent
public int getKeyEvent()If this event was triggered by a key press this method will return the appropriate keycode
Returns
the key that triggered the event
-
getProgress
public int getProgress()Returns the numeric progress of native browser loading on Android
Returns
the progress value
-
getCommand
If this event was sent as a result of a command action this method returns that command
Returns
the command action that triggered the action event
-
getActualComponent
Identical to
ActionEvent#getComponent()except for the fact that a lead component will be returned if such a lead component is available. This is important for components such ascom.codename1.components.MultiButtonwhich will return the underlying button instead.Returns
the component that sent the event
-
getComponent
Returns the component that generated the event. important this might not be the actual component. In case of a lead component such as
com.codename1.components.MultiButtonthe underlyingcom.codename1.ui.Buttonwill be returned and not thecom.codename1.components.MultiButtonitself. To get the component that you would logically think of as the source component use the#getActualComponentmethod.If you are in doubt use the
getActualComponentmethod.Returns
a component
See also
- ActionEvent#getActualComponent() - you should probably use
getActualComponentinstead of this method
- ActionEvent#getActualComponent() - you should probably use
-
consume
public void consume()Consume the event indicating that it was handled thus preventing other action listeners from handling/receiving the event -
isConsumed
public boolean isConsumed()Returns true if the event was consumed thus indicating that it was handled. This prevents other action listeners from handling/receiving the event
Returns
true if the event was consumed
-
getX
public int getX()The X position if this is a pointer event otherwise undefined
Returns
x position
-
getY
public int getY()The Y position if this is a pointer event otherwise undefined
Returns
y position
-
isLongEvent
public boolean isLongEvent()Returns true for long click or long pointer event -
getDraggedComponent
Set in the case of a drop listener, returns the component being dragged
Returns
the component being dragged
-
getDropTarget
Set in the case of a drop listener, returns the component on which the drop occurs
Returns
the component on which the drop occurs
-
isPointerPressedDuringDrag
public boolean isPointerPressedDuringDrag()Only used for pointer dragged events. This flag is set to true if a pointer press event was silently swallowed by a drag in progress. While dragging and scrolling is in progress, pointer pressed events are not delivered. This allows you to detect if a pointer press occurred during a scroll or drag.
Since
8.0
-
setPointerPressedDuringDrag
public void setPointerPressedDuringDrag(boolean pressed) Only used for pointer dragged events. This flag is set to true if a pointer press event was silently swallowed by a drag in progress. While dragging and scrolling is in progress, pointer pressed events are not delivered. This allows you to detect if a pointer press occurred during a scroll or drag.
Since
8.0
-