Package ej.mwt.event
Class EventDispatcher
- java.lang.Object
-
- ej.mwt.event.EventDispatcher
-
- Direct Known Subclasses:
PointerEventDispatcher
public abstract class EventDispatcher extends java.lang.ObjectDispatches the events received on a desktop to its children.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedEventDispatcher(Desktop desktop)Creates an event dispatcher.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleandispatchEvent(int event)Dispatches an event.voiddispose()Disposes this event dispatcher.DesktopgetDesktop()Returns the desktop managed by this dispatcher.voidinitialize()Initializes this event dispatcher.booleanisInitialized()Gets whether this event dispatcher has been initialized.protected booleansendEventToWidget(Widget widget, int event)Sends the given event to the given widget.protected WidgetsendEventToWidgetHierarchy(Widget hierarchyLeaf, int event)Sends the given event to the given widget and to each of its ancestors.
-
-
-
Constructor Detail
-
EventDispatcher
protected EventDispatcher(Desktop desktop)
Creates an event dispatcher.- Parameters:
desktop- the desktop to dispatch in.
-
-
Method Detail
-
getDesktop
public Desktop getDesktop()
Returns the desktop managed by this dispatcher.- Returns:
- the desktop managed by this dispatcher.
-
dispatchEvent
public abstract boolean dispatchEvent(int event)
Dispatches an event.- Parameters:
event- the event to dispatch.- Returns:
trueif the event dispatcher has dealt with the event,falseotherwise.
-
initialize
public void initialize()
Initializes this event dispatcher.For example, this method can be used to create an event generator.
-
dispose
public void dispose()
Disposes this event dispatcher.After this call, all that has been allocated or started in the
initialize()method must be disposed or stopped.
-
isInitialized
public boolean isInitialized()
Gets whether this event dispatcher has been initialized.It is set as not initialized when disposed.
- Returns:
trueif this event dispatcher has been initialized,falseotherwise
-
sendEventToWidget
protected boolean sendEventToWidget(Widget widget, int event)
Sends the given event to the given widget.- Parameters:
widget- the widget to which the event should be sent.event- the event to send.- Returns:
trueif the widget has consumed the event,falseotherwise.
-
sendEventToWidgetHierarchy
@Nullable protected Widget sendEventToWidgetHierarchy(Widget hierarchyLeaf, int event)
Sends the given event to the given widget and to each of its ancestors.If the event is consumed by one of the widgets, it is not sent to its ancestors.
- Parameters:
hierarchyLeaf- the leaf of the hierarchy to which the event should be sent.event- the event to send.- Returns:
- the widget which has consumed the event, or
nullif the event has not been consumed.
-
-