Package ej.mwt.event

Class EventDispatcher

  • Direct Known Subclasses:
    PointerEventDispatcher

    public abstract class EventDispatcher
    extends java.lang.Object
    Dispatches the events received on a desktop to its children.
    • Constructor Detail

      • EventDispatcher

        public 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.

      • 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.