Package ej.mwt.event

## Class EventDispatcher

- java.lang.Object
- - ej.mwt.event.EventDispatcher

- Direct Known Subclasses:
    `PointerEventDispatcher`

      public abstract class EventDispatcher
      extends Object

  Dispatches the events received on a desktop to its children.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `EventDispatcher​(Desktop desktop)` | Creates an event dispatcher.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract boolean` | `dispatchEvent​(int event)` | Dispatches an event.
    `void` | `dispose()` | Disposes this event dispatcher.
    `Desktop` | `getDesktop()` | Returns the desktop managed by this dispatcher.
    `void` | `initialize()` | Initializes this event dispatcher.
    `boolean` | `isInitialized()` | Gets whether this event dispatcher has been initialized.
    `protected boolean` | `sendEventToWidget​(Widget widget, int event)` | Sends the given event to the given widget.
    `protected Widget` | `sendEventToWidgetHierarchy​(Widget hierarchyLeaf, int event)` | Sends the given event to the given widget and to each of its ancestors.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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:
        `true` if the event dispatcher has dealt with the event, `false` otherwise.

    - #### 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:
        `true` if this event dispatcher has been initialized, `false` otherwise

    - #### 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:
        `true` if the widget has consumed the event, `false` otherwise.

    - #### 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 `null` if the event has not been consumed.