Class EventTarget

    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private EventListenersContainer eventListenersContainer_  
      • Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
      • Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

        NOT_FOUND
    • Constructor Summary

      Constructors 
      Constructor Description
      EventTarget()
      Default constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEventListener​(java.lang.String type, org.htmlunit.corejs.javascript.Scriptable listener, boolean useCapture)
      Allows the registration of event listeners on the event target.
      protected void clearEventListenersContainer()
      Clears the event listener container.
      boolean dispatchEvent​(Event event)
      Dispatches an event into the event system (standards-conformant browsers only).
      void executeEventLocally​(Event event)
      Executes the event on this object only (needed for instance for onload on (i)frame tags).
      ScriptResult fireEvent​(Event event)
      Fires the event on the node with capturing and bubbling phase.
      org.htmlunit.corejs.javascript.Function getEventHandler​(java.lang.String eventType)
      Returns the specified event handler.
      EventListenersContainer getEventListenersContainer()
      Gets the container for event listeners.
      boolean hasEventHandlers​(java.lang.String eventName)
      Returns true if there are any event handlers for the specified event.
      protected boolean isEventHandlerOnWindow()
      Is setting event handler property, at window-level.
      void jsConstructor()
      JavaScript constructor.
      void removeEventListener​(java.lang.String type, org.htmlunit.corejs.javascript.Scriptable listener, boolean useCapture)
      Allows the removal of event listeners on the event target.
      void setEventHandler​(java.lang.String eventName, java.lang.Object value)
      Defines an event handler (or maybe any other object).
      • Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EventTarget

        public EventTarget()
        Default constructor.
    • Method Detail

      • jsConstructor

        public void jsConstructor()
        JavaScript constructor.
      • addEventListener

        public void addEventListener​(java.lang.String type,
                                     org.htmlunit.corejs.javascript.Scriptable listener,
                                     boolean useCapture)
        Allows the registration of event listeners on the event target.
        Parameters:
        type - the event type to listen for (like "click")
        listener - the event listener
        useCapture - If true, indicates that the user wishes to initiate capture
        See Also:
        Mozilla documentation
      • getEventListenersContainer

        public final EventListenersContainer getEventListenersContainer()
        Gets the container for event listeners.
        Returns:
        the container (newly created if needed)
      • executeEventLocally

        public void executeEventLocally​(Event event)
        Executes the event on this object only (needed for instance for onload on (i)frame tags).
        Parameters:
        event - the event
        See Also:
        fireEvent(Event)
      • fireEvent

        public ScriptResult fireEvent​(Event event)
        Fires the event on the node with capturing and bubbling phase.
        Parameters:
        event - the event
        Returns:
        the result
      • hasEventHandlers

        public boolean hasEventHandlers​(java.lang.String eventName)
        Returns true if there are any event handlers for the specified event.
        Parameters:
        eventName - the event name (e.g. "onclick")
        Returns:
        true if there are any event handlers for the specified event, false otherwise
      • getEventHandler

        public org.htmlunit.corejs.javascript.Function getEventHandler​(java.lang.String eventType)
        Returns the specified event handler.
        Parameters:
        eventType - the event type (e.g. "click")
        Returns:
        the handler function, or null if the property is null or not a function
      • dispatchEvent

        public boolean dispatchEvent​(Event event)
        Dispatches an event into the event system (standards-conformant browsers only). See the Gecko DOM reference for more information.
        Parameters:
        event - the event to be dispatched
        Returns:
        false if at least one of the event handlers which handled the event called preventDefault; true otherwise
      • removeEventListener

        public void removeEventListener​(java.lang.String type,
                                        org.htmlunit.corejs.javascript.Scriptable listener,
                                        boolean useCapture)
        Allows the removal of event listeners on the event target.
        Parameters:
        type - the event type to listen for (like "click")
        listener - the event listener
        useCapture - If true, indicates that the user wishes to initiate capture (not yet implemented)
        See Also:
        Mozilla documentation
      • setEventHandler

        public void setEventHandler​(java.lang.String eventName,
                                    java.lang.Object value)
        Defines an event handler (or maybe any other object).
        Parameters:
        eventName - the event name (e.g. "click")
        value - the property (null to reset it)
      • isEventHandlerOnWindow

        protected boolean isEventHandlerOnWindow()
        Is setting event handler property, at window-level.
        Returns:
        whether the event handler to be set at window-level
      • clearEventListenersContainer

        protected void clearEventListenersContainer()
        Clears the event listener container.