Module org.htmlunit

Class EventListenersContainer

java.lang.Object
org.htmlunit.javascript.host.event.EventListenersContainer
All Implemented Interfaces:
Serializable

public class EventListenersContainer extends Object implements Serializable
Container for event listeners.
Author:
Marc Guillemot, Daniel Gredler, Ahmed Ashour, Frank Danek, Ronald Brill, Atsushi Nakagawa
See Also:
  • Constructor Details

    • EventListenersContainer

      public EventListenersContainer(EventTarget jsNode)
      Creates a new container for the given event target node.
      Parameters:
      jsNode - the node
  • Method Details

    • addEventListener

      public boolean addEventListener(String type, org.htmlunit.corejs.javascript.Scriptable listener, boolean useCapture)
      Adds an event listener.
      Parameters:
      type - the event type to listen for (e.g. "load")
      listener - the event listener
      useCapture - if true, the listener is added for the capture phase
      Returns:
      true if the listener was added; false if it was already registered
    • getListeners

      public List<org.htmlunit.corejs.javascript.Scriptable> getListeners(String eventType, boolean useCapture)
      Returns the listeners for the given event type and capture mode.
      Parameters:
      eventType - the event type
      useCapture - whether to return capture-phase listeners
      Returns:
      the list of listeners (empty list if none)
    • setEventHandler

      public void setEventHandler(String eventType, Object value)
      Sets the property handler for the given event type.
      Parameters:
      eventType - the event type (e.g. "click")
      value - the new handler, or null to remove it
    • executeBubblingListeners

      public void executeBubblingListeners(Event event, Object[] args)
      Executes bubbling listeners for the given event.
      Parameters:
      event - the event
      args - the arguments
    • executeCapturingListeners

      public void executeCapturingListeners(Event event, Object[] args)
      Executes capturing listeners for the given event.
      Parameters:
      event - the event
      args - the arguments
    • executeAtTargetListeners

      public void executeAtTargetListeners(Event event, Object[] args)
      Executes listeners for events targeting this node (non-propagation phase).
      Parameters:
      event - the event
      args - the arguments
    • getEventHandler

      public org.htmlunit.corejs.javascript.Function getEventHandler(String eventType)
      Returns the event handler function for the given event type.
      Parameters:
      eventType - the event type (e.g. "click")
      Returns:
      the handler function, or null if not set
    • toString

      public String toString()
      Overrides:
      toString in class Object