Interface EventTarget

All Known Subinterfaces:
BodyElement, ButtonElement, CanvasElement, ComponentElement, DelphiElement, Document, Element, HeadElement, InputElement, ItemElement, JavaObjectElement, OptionElement, ScriptElement, StyleElement

public interface EventTarget
An object which can host event listeners and be the target of Event dispatches
  • Method Details

    • addEventListener

      void addEventListener(String eventType, EventListener listener)
      Adds an event listener to the specified type.
      Parameters:
      eventType - Event type
      listener - Event listener
      Throws:
      NullPointerException - if either eventType or listener is null
    • removeEventListener

      boolean removeEventListener(String eventType, EventListener listener)
      Removes an event listener.

      If either the eventType or listener is null, this return false.

      Parameters:
      eventType - Event type
      listener - Event listener
      Returns:
      true, if the listener was registered for the specified eventType and was removed, false otherwise.
      Throws:
      NullPointerException - if either eventType or listener is null
    • dispatchEvent

      void dispatchEvent(Event event)
      Dispatches an event.

      Events are executed first by the target they are dispatched on. Then, if the event is set to bubble (with Event.isBubbling()) then it will bubble up through the document tree.
      Finally, the event will be dispatched to Document.getGlobalTarget(), unless the event has been cancelled.

      Parameters:
      event - Event to dispatch
      Throws:
      NullPointerException - if event is null
    • onClick

      void onClick(@Nullable EventListener.Typed<MouseEvent> listener)
      Set the click listener. The set listener will only be called when a player left-clicks the target.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.CLICK events.

      Parameters:
      listener - Click listener
    • getOnClick

      @Nullable EventListener.Typed<MouseEvent> getOnClick()
      Get the left-click listener
      Returns:
      Click listener, or null, if not set
    • onRightClick

      void onRightClick(@Nullable EventListener.Typed<MouseEvent> listener)
      Set the right-click listener.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.CLICK events.

      Parameters:
      listener - Right click listener
    • getOnRightClick

      @Nullable EventListener.Typed<MouseEvent> getOnRightClick()
      Get the right-click listener
      Returns:
      Click listener, or null, if not set
    • onMouseEnter

      void onMouseEnter(@Nullable EventListener.Typed<MouseEvent> listener)
      Set the mouse enter listener. The listener is called when a player's cursor enters the target.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MOUSE_ENTER events.

      Parameters:
      listener - Mouse enter listener
    • getOnMouseEnter

      @Nullable EventListener.Typed<MouseEvent> getOnMouseEnter()
      Get the mouse enter listener.
      Returns:
      Mouse enter listener, or null, if not set
    • onMouseExit

      void onMouseExit(@Nullable EventListener.Typed<MouseEvent> listener)
      Set the mouse exit listener. The listener is called when a player's cursor exits the target.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MOUSE_LEAVE events.

      Parameters:
      listener - Mouse exit listener
    • getOnMouseExit

      @Nullable EventListener.Typed<MouseEvent> getOnMouseExit()
      Get the mouse exit listener.
      Returns:
      Mouse exit listener, or null, if not set
    • onMouseMove

      void onMouseMove(@Nullable EventListener.Typed<MouseEvent> listener)
      Set the mouse move listener. The listener is only called when a player's cursor moves inside the target. If a player's cursor exits or enters the target, the listener is not called.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MOUSE_MOVE events.

      Parameters:
      listener - Mouse move listener
    • getOnMouseMove

      @Nullable EventListener.Typed<MouseEvent> getOnMouseMove()
      Get the mouse move listener.
      Returns:
      Mouse move listener, or null, if not set
    • onAppendChild

      void onAppendChild(@Nullable EventListener.Typed<MutationEvent> listener)
      Set the append listener. The listener is called when a child Node is appended to the target.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.APPEND_CHILD events.

      Parameters:
      listener - Child append listener
    • getOnAppendChild

      @Nullable EventListener.Typed<MutationEvent> getOnAppendChild()
      Get the append listener.
      Returns:
      append listener, or null, if not set
    • onRemoveChild

      void onRemoveChild(@Nullable EventListener.Typed<MutationEvent> listener)
      Set the remove child listener. The listener is called when a child Node is removed from the target.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.REMOVE_CHILD events.

      Parameters:
      listener - Child remove listener
    • getOnRemoveChild

      @Nullable EventListener.Typed<MutationEvent> getOnRemoveChild()
      Get the remove child listener.
      Returns:
      remove child listener, or null, if not set
    • onAttributeChange

      void onAttributeChange(@Nullable EventListener.Typed<AttributeMutateEvent> listener)
      Set the attribute change listener. The listener is called whenever any change is made to an attribute's value.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MODIFY_ATTR events.

      Parameters:
      listener - Attribute listener
    • getOnAttributeChange

      @Nullable EventListener.Typed<AttributeMutateEvent> getOnAttributeChange()
      Get the attribute change listener.
      Returns:
      attribute change listener, or null, if not set
    • onSetAttribute

      void onSetAttribute(@Nullable EventListener.Typed<AttributeMutateEvent> listener)
      Set the attribute set listener. The listener is called whenever an existing attribute's value is set.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MODIFY_ATTR events.

      Parameters:
      listener - Attribute set listener
    • getOnSetAttribute

      @Nullable EventListener.Typed<AttributeMutateEvent> getOnSetAttribute()
      Get the attribute set listener.
      Returns:
      attribute set listener, or null, if not set
    • onRemoveAttribute

      void onRemoveAttribute(@Nullable EventListener.Typed<AttributeMutateEvent> listener)
      Set the attribute removal listener. The listener is called whenever an existing attribute's value is removed.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MODIFY_ATTR events.

      Parameters:
      listener -
    • getOnRemoveAttribute

      @Nullable EventListener.Typed<AttributeMutateEvent> getOnRemoveAttribute()
      Get the attribute remove listener.
      Returns:
      attribute remove listener, or null, if not set
    • onAddAttribute

      void onAddAttribute(@Nullable EventListener.Typed<AttributeMutateEvent> listener)
      Set the attribute addition listener. The listener is called whenever a new attribute is set.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MODIFY_ATTR events.

      Parameters:
      listener - Attribute addition listener
    • getOnAddAttribute

      @Nullable EventListener.Typed<AttributeMutateEvent> getOnAddAttribute()
      Get the attribute addition listener.
      Returns:
      attribute addition listener, or null, if not set
    • onOptionChange

      void onOptionChange(@Nullable EventListener.Typed<AttributeMutateEvent> listener)
      Set the option change listener. The listener is called whenever any change is made to an document option's value.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MODIFY_OPTION events.

      Parameters:
      listener - Option listener
    • getOnOptionChange

      @Nullable EventListener.Typed<AttributeMutateEvent> getOnOptionChange()
      Get the option change listener.
      Returns:
      option change listener, or null, if not set
    • onSetOption

      void onSetOption(@Nullable EventListener.Typed<AttributeMutateEvent> listener)
      Set the option set listener. The listener is called whenever an existing document option's value is set.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MODIFY_OPTION events.

      Parameters:
      listener - Option set listener
    • getOnSetOption

      @Nullable EventListener.Typed<AttributeMutateEvent> getOnSetOption()
      Get the option set listener.
      Returns:
      option set listener, or null, if not set
    • onRemoveOption

      void onRemoveOption(@Nullable EventListener.Typed<AttributeMutateEvent> listener)
      Set the option removal listener. The listener is called whenever an existing document option's value is removed.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MODIFY_OPTION events.

      Parameters:
      listener - Option remove listener
    • getOnRemoveOption

      @Nullable EventListener.Typed<AttributeMutateEvent> getOnRemoveOption()
      Get the option removal listener.
      Returns:
      option removal listener, or null, if not set
    • onAddOption

      void onAddOption(@Nullable EventListener.Typed<AttributeMutateEvent> listener)
      Set the option addition listener. The listener is called whenever a new document option is set.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.MODIFY_OPTION events.

      Parameters:
      listener - Option addition listener
    • getOnAddOption

      @Nullable EventListener.Typed<AttributeMutateEvent> getOnAddOption()
      Get the option addition listener.
      Returns:
      option addition listener, or null, if not set
    • onInput

      void onInput(@Nullable EventListener.Typed<InputEvent> listener)
      Set the input listener. The listener is called whenever the input of an InputElement is changed, either by player or by calling the InputElement.setValue(String) method.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.INPUT events.

      Parameters:
      listener - Input listener
    • getOnInput

      @Nullable EventListener.Typed<InputEvent> getOnInput()
      Get the input listener.
      Returns:
      input listener, or null, if not set
    • onLoaded

      void onLoaded(@Nullable @Nullable EventListener listener)
      Set the DOM loaded listener. The listener is called when the DOM tree is finished loading.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.DOM_LOADED events.

      Parameters:
      listener - DOM loaded listener
    • getOnLoaded

      @Nullable EventListener.Typed<InputEvent> getOnLoaded()
      Get the DOM loaded listener.
      Returns:
      DOM loaded listener, or null, if not set
    • onSpawned

      void onSpawned(@Nullable @Nullable EventListener listener)
      Set the DOM spawned listener. The listener is called when the document view is spawned and becomes visible to players.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.DOM_SPAWNED events.

      Parameters:
      listener - Spawn listener
    • getOnSpawned

      @Nullable @Nullable EventListener getOnSpawned()
      Get the DOM spawned listener.
      Returns:
      DOM spawned listener, or null, if not set
    • onClosing

      void onClosing(@Nullable @Nullable EventListener listener)
      Set the DOM closing listener. The listener is called when the document view starts closing.

      Can be removed by setting this to null and overridden by calling this method again

      Listens to EventTypes.DOM_CLOSING events.

      Parameters:
      listener - Closing listener
    • getOnClosing

      @Nullable @Nullable EventListener getOnClosing()
      Get the DOM closing listener.
      Returns:
      DOM closing listener, or null, if not set