public class ActionEvent
- Object
- ActionEvent
Known subtypesNetworkEvent, AsyncMedia.MediaErrorEvent, AsyncMedia.MediaStateChangeEvent, PluginEvent, NativeDropEvent, ComponentStateChangeEvent, MessageEvent, WheelEvent, WindowEvent
Event object delivered when an
ActionListener callback is invokedNested types
enum ActionEvent.Type | The event type, as declared when the event is created. |
Constructors
Methods
public ActionEvent.Type getEventType() | Returns the type of the given event allowing us to have more generic event handling code and useful for debugging |
public Object getSource() | The element that triggered the action event, useful for decoupling event handling code |
public int getKeyEvent() | If this event was triggered by a key press this method will return the appropriate keycode |
public int getProgress() | Returns the numeric progress of native browser loading on Android |
public Command getCommand() | If this event was sent as a result of a command action this method returns that command |
public Component getActualComponent() | Identical to ActionEvent#getComponent() except for the fact that a lead component will be returned if such a lead component is available. |
public Component getComponent() | Returns the component that generated the event. |
public void consume() | Consume the event indicating that it was handled thus preventing other action listeners from handling/receiving the event |
public boolean isConsumed() | Returns true if the event was consumed thus indicating that it was handled. |
public int getX() | The X position if this is a pointer event otherwise undefined |
public int getY() | The Y position if this is a pointer event otherwise undefined |
public boolean isLongEvent() | Returns true for long click or long pointer event |
public PointerEvent getPointerEvent() | Returns the rich pointer detail for this event such as the triggering mouse button, the pointing device type (finger, mouse, stylus or eraser), the pressure applied and the stylus tilt. |
public void setPointerEvent(PointerEvent pointerEvent) | Attaches an explicit rich pointer detail snapshot to this event. |
public Component getDraggedComponent() | Set in the case of a drop listener, returns the component being dragged |
public Component getDropTarget() | Set in the case of a drop listener, returns the component on which the drop occurs |
public boolean isPointerPressedDuringDrag() | Only used for pointer dragged events. |
public void setPointerPressedDuringDrag(boolean pressed) | Only used for pointer dragged events. |
Inherited methods
Constructor details
ActionEvent
public ActionEvent(Object source)Creates a new instance of ActionEvent. This is unused locally, but provided so existing customer code
with still work.
Parameters
sourceObject- element for the action event
ActionEvent
public ActionEvent(Object source, ActionEvent.Type type)Creates a new instance of ActionEvent
Parameters
sourceObject- element for the action event
typeActionEvent.Type- the
Typeof the event
ActionEvent
public ActionEvent(Object source, ActionEvent.Type type, int x, int y)Creates a new instance of ActionEvent as a pointer event
Parameters
sourceObject- element for the pointer event
typeActionEvent.Type- the
Typeof the event xint- (or sometimes width) associated with the event
yint- (or sometimes height)associated with the event
ActionEvent
public ActionEvent(Command source, ActionEvent.Type type, Component sourceComponent, int x, int y)Creates a new instance of ActionEvent for a command
Parameters
sourceCommand- element command
typeActionEvent.Type- the
Typeof the event sourceComponentComponent- the triggering component
xint- the x position of the pointer event
yint- the y position of the pointer event
ActionEvent
public ActionEvent(Component dragged, ActionEvent.Type type, Component drop, int x, int y)Creates a new instance of ActionEvent for a drop operation
Parameters
draggedComponent- the dragged component
typeActionEvent.Type- the
Typeof the event dropComponent- the drop target component
xint- the x position of the pointer event
yint- the y position of the pointer event
ActionEvent
public ActionEvent(Object source, ActionEvent.Type type, int keyEvent)Creates a new instance of ActionEvent. The key event is really just
a numeric code, not indicative of a key press
Parameters
sourceObject- element for the action event
typeActionEvent.Type- the
Typeof the event keyEventint- the key that triggered the event
ActionEvent
public ActionEvent(Object source, int keyEvent)Creates a new instance of ActionEvent
Parameters
sourceObject- element for the action event
keyEventint- the key that triggered the event
ActionEvent
public ActionEvent(Object source, int keyEvent, boolean longClick)Creates a new instance of ActionEvent
Parameters
sourceObject- element for the action event
keyEventint- the key that triggered the event
longClickboolean- true if the event is triggered from long pressed
ActionEvent
public ActionEvent(Object source, int x, int y, boolean longPointer)Creates a new instance of ActionEvent as a pointer event
Parameters
sourceObject- element for the pointer event
xint- the x position of the pointer event
yint- the y position of the pointer event
longPointerboolean- true if the event is triggered from long pressed
ActionEvent
public ActionEvent(Object source, int x, int y)Creates a new instance of ActionEvent as a generic pointer event.
Parameters
sourceObject- element for the pointer event
xint- the x position of the pointer event
yint- the y position of the pointer event
ActionEvent
public ActionEvent(Command source, Component sourceComponent, int x, int y)Creates a new instance of ActionEvent for a command
Parameters
sourceCommand- element command
sourceComponentComponent- the triggering component
xint- the x position of the pointer event
yint- the y position of the pointer event
ActionEvent
public ActionEvent(Component dragged, Component drop, int x, int y)Creates a new instance of ActionEvent for a drop operation
Parameters
draggedComponent- the dragged component
dropComponent- the drop target component
xint- the x position of the pointer event
yint- the y position of the pointer event
Method details
getEventType
public ActionEvent.Type 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
public Object 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
public Command 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
public Component 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 as com.codename1.components.MultiButton
which will return the underlying button instead.Returns
the component that sent the event
getComponent
public Component 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.MultiButton the underlying
com.codename1.ui.Button will be returned and not the com.codename1.components.MultiButton
itself. To get the component that you would logically think of as the source component use the #getActualComponent
method.
If you are in doubt use the getActualComponent method.
Returns
a component
See also
ActionEvent#getActualComponent()- you should probably use `getActualComponent` instead of this method
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
getPointerEvent
public PointerEvent getPointerEvent()Returns the rich pointer detail for this event such as the triggering mouse button, the
pointing device type (finger, mouse, stylus or eraser), the pressure applied and the stylus
tilt. For pointer events that did not have an explicit snapshot attached this falls back to
the pointer event currently being dispatched, so the detail is available from any pointer
listener. Returns null for non pointer events.
Returns
the
PointerEvent detail or null when this is not a pointer eventsetPointerEvent
public void setPointerEvent(PointerEvent pointerEvent)Attaches an explicit rich pointer detail snapshot to this event.
Parameters
pointerEventPointerEvent- the snapshot to attach
getDraggedComponent
public Component getDraggedComponent()Set in the case of a drop listener, returns the component being dragged
Returns
the component being dragged
getDropTarget
public Component 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.
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.