Class BaseEventTarget

  • Direct Known Subclasses:
    BaseNode

    @JsType(isNative=true,
            name="EventTarget",
            namespace="<global>")
    public abstract class BaseEventTarget
    extends Object
    Base DOM entity extended by objects that can receive events and may have listeners for them.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • addEventListener

        @JsMethod
        public final void addEventListener​(String type,
                                           CallbackProxy.Proxy listener)
        Sets up a function that will be called whenever the specified event is delivered to the target.
        Parameters:
        type - a case-sensitive string representing the event type to listen for
        listener - the object which receives a notification when an event of the specified type occurs
      • removeEventListener

        @JsMethod
        public final void removeEventListener​(String type,
                                              CallbackProxy.Proxy listener)
        Removes from the event target an event listener previously registered.
        The event listener to be removed is identified using a combination of the event type and the event listener function itself.
        Parameters:
        type - a string which specifies the type of event for which to remove an event listener
        listener - function instance of the event handler to remove from the event target.
      • dispatchEvent

        @JsMethod
        public final boolean dispatchEvent​(NativeBaseEvent event)
        Dispatches an NativeBaseEvent at the specified BaseEventTarget, (synchronously) invoking the affected event listeners in the appropriate order.
        Parameters:
        event - the NativeBaseEvent instance to be dispatched.
        Returns:
        false if event is cancelable and at least one of the event handlers which received event called NativeBaseEvent.preventDefault(), otherwise it returns true.
      • addEventListener

        @JsOverlay
        public final void addEventListener​(IsEvent type,
                                           CallbackProxy.Proxy listener)
        Sets up a function that will be called whenever the specified event is delivered to the target.
        Parameters:
        type - a case-sensitive string representing the event type to listen for
        listener - the object which receives a notification when an event of the specified type occurs
      • removeEventListener

        @JsOverlay
        public final void removeEventListener​(IsEvent type,
                                              CallbackProxy.Proxy listener)
        Removes from the event target an event listener previously registered.
        The event listener to be removed is identified using a combination of the event type and the event listener function itself.
        Parameters:
        type - a string which specifies the type of event for which to remove an event listener
        listener - function instance of the event handler to remove from the event target.
      • dispatchEvent

        @JsOverlay
        public final boolean dispatchEvent​(HasNativeEvent event)
        Dispatches an AbstractEvent at the specified BaseEventTarget, (synchronously) invoking the affected event listeners in the appropriate order.
        Parameters:
        event - the AbstractEvent instance to be dispatched.
        Returns:
        false if event is cancelable and at least one of the event handlers which received event called NativeBaseEvent.preventDefault(), otherwise it returns true.