public class ActionEvent

  1. Object
  2. ActionEvent

Known subtypesNetworkEvent, AsyncMedia.MediaErrorEvent, AsyncMedia.MediaStateChangeEvent, PluginEvent, NativeDropEvent, ComponentStateChangeEvent, MessageEvent, WheelEvent, WindowEvent

Event object delivered when an ActionListener callback is invoked

Nested types

enum ActionEvent.TypeThe event type, as declared when the event is created.

Constructors

public ActionEvent(Object source)Creates a new instance of ActionEvent.
public ActionEvent(Object source, ActionEvent.Type type)Creates a new instance of ActionEvent
public ActionEvent(Object source, ActionEvent.Type type, int x, int y)Creates a new instance of ActionEvent as a pointer event
public ActionEvent(Command source, ActionEvent.Type type, Component sourceComponent, int x, int y)Creates a new instance of ActionEvent for a command
public ActionEvent(Component dragged, ActionEvent.Type type, Component drop, int x, int y)Creates a new instance of ActionEvent for a drop operation
public ActionEvent(Object source, ActionEvent.Type type, int keyEvent)Creates a new instance of ActionEvent.
public ActionEvent(Object source, int keyEvent)Creates a new instance of ActionEvent
public ActionEvent(Object source, int keyEvent, boolean longClick)Creates a new instance of ActionEvent
public ActionEvent(Object source, int x, int y, boolean longPointer)Creates a new instance of ActionEvent as a pointer event
public ActionEvent(Object source, int x, int y)Creates a new instance of ActionEvent as a generic pointer event.
public ActionEvent(Command source, Component sourceComponent, int x, int y)Creates a new instance of ActionEvent for a command
public ActionEvent(Component dragged, Component drop, int x, int y)Creates a new instance of ActionEvent for a drop operation

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

source Object
element for the action event

ActionEvent

public ActionEvent(Object source, ActionEvent.Type type)
Creates a new instance of ActionEvent

Parameters

source Object
element for the action event
type ActionEvent.Type
the Type of 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

source Object
element for the pointer event
type ActionEvent.Type
the Type of the event
x int
(or sometimes width) associated with the event
y int
(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

source Command
element command
type ActionEvent.Type
the Type of the event
sourceComponent Component
the triggering component
x int
the x position of the pointer event
y int
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

dragged Component
the dragged component
type ActionEvent.Type
the Type of the event
drop Component
the drop target component
x int
the x position of the pointer event
y int
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

source Object
element for the action event
type ActionEvent.Type
the Type of the event
keyEvent int
the key that triggered the event

ActionEvent

public ActionEvent(Object source, int keyEvent)
Creates a new instance of ActionEvent

Parameters

source Object
element for the action event
keyEvent int
the key that triggered the event

ActionEvent

public ActionEvent(Object source, int keyEvent, boolean longClick)
Creates a new instance of ActionEvent

Parameters

source Object
element for the action event
keyEvent int
the key that triggered the event
longClick boolean
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

source Object
element for the pointer event
x int
the x position of the pointer event
y int
the y position of the pointer event
longPointer boolean
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

source Object
element for the pointer event
x int
the x position of the pointer event
y int
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

source Command
element command
sourceComponent Component
the triggering component
x int
the x position of the pointer event
y int
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

dragged Component
the dragged component
drop Component
the drop target component
x int
the x position of the pointer event
y int
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

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 event

setPointerEvent

public void setPointerEvent(PointerEvent pointerEvent)
Attaches an explicit rich pointer detail snapshot to this event.

Parameters

pointerEvent PointerEvent
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.