Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class ActionEvent
- Object
- ActionEvent
Known subtypesNetworkEvent, AsyncMedia.MediaErrorEvent, AsyncMedia.MediaStateChangeEvent, PluginEvent, NativeDropEvent, AnimationEvent, ComponentStateChangeEvent, MessageEvent, WheelEvent, WindowEvent
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)Parameters
sourceObject- element for the action event
ActionEvent
public ActionEvent(Object source, ActionEvent.Type type)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)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)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)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)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)Parameters
sourceObject- element for the action event
keyEventint- the key that triggered the event
ActionEvent
public ActionEvent(Object source, int keyEvent, boolean longClick)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)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)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)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)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
getSource
public Object getSource()Returns
getKeyEvent
public int getKeyEvent()Returns
getProgress
public int getProgress()Returns
getCommand
public Command getCommand()Returns
getActualComponent
public Component getActualComponent()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
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
See also
ActionEvent#getActualComponent()- you should probably use `getActualComponent` instead of this method
consume
public void consume()isConsumed
public boolean isConsumed()Returns
getX
public int getX()Returns
getY
public int getY()Returns
isLongEvent
public boolean isLongEvent()getPointerEvent
public PointerEvent getPointerEvent()Returns
PointerEvent detail or null when this is not a pointer eventsetPointerEvent
public void setPointerEvent(PointerEvent pointerEvent)Parameters
pointerEventPointerEvent- the snapshot to attach
getDraggedComponent
public Component getDraggedComponent()Returns
getDropTarget
public Component getDropTarget()Returns
isPointerPressedDuringDrag
public boolean isPointerPressedDuringDrag()setPointerPressedDuringDrag
public void setPointerPressedDuringDrag(boolean pressed)