Interface IEventTarget

Interface IEventTarget

Namespace: Aspose.Html.Dom.Events
Assembly: Aspose.HTML.dll (25.2.0)

The Aspose.Html.Dom.EventTarget interface is implemented by all Nodes in an implementation which supports the DOM Event Model. Therefore, this interface can be obtained by using binding-specific casting methods on an instance of the Node interface. The interface allows registration and removal of Event Listeners on an Aspose.Html.Dom.EventTarget and dispatch of events to that Aspose.Html.Dom.Events.IEventTarget.

[ComVisible(true)]
[DOMNoInterfaceObject]
public interface IEventTarget

Methods

AddEventListener(string, IEventListener)

This method allows the registration of event listeners on the event target.

[DOMName("addEventListener")]
void AddEventListener(string type, IEventListener listener)

Parameters

type string

The event type for which the user is registering

listener IEventListener

Takes an interface implemented by the user which contains the methods to be called when the event occurs.

Remarks

If an Aspose.Html.Dom.Events.IEventListener is added to an Aspose.Html.Dom.EventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.

If multiple identical Event Listeners are registered on the same Aspose.Html.Dom.EventTarget with the same parameters the duplicate instances are discarded. They do not cause the Aspose.Html.Dom.Events.IEventListener to be called twice and since they are discarded they do not need to be removed with the Aspose.Html.Dom.Events.IEventTarget.RemoveEventListener(System.String,Aspose.Html.Dom.Events.IEventListener) method.

AddEventListener(string, IEventListener, bool)

This method allows the registration of event listeners on the event target.

[DOMName("addEventListener")]
void AddEventListener(string type, IEventListener listener, bool useCapture)

Parameters

type string

The event type for which the user is registering

listener IEventListener

Takes an interface implemented by the user which contains the methods to be called when the event occurs.

useCapture bool

If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered Aspose.Html.Dom.Events.IEventListener before being dispatched to any Event Targets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an Aspose.Html.Dom.Events.IEventListener designated to use capture.

Remarks

If an Aspose.Html.Dom.Events.IEventListener is added to an Aspose.Html.Dom.EventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.

If multiple identical Event Listeners are registered on the same Aspose.Html.Dom.EventTarget with the same parameters the duplicate instances are discarded. They do not cause the Aspose.Html.Dom.Events.IEventListener to be called twice and since they are discarded they do not need to be removed with the Aspose.Html.Dom.Events.IEventTarget.RemoveEventListener(System.String,Aspose.Html.Dom.Events.IEventListener) method.

DispatchEvent(Event)

This method allows the dispatch of events into the implementations event model.

[DOMName("dispatchEvent")]
bool DispatchEvent(Event @event)

Parameters

event Event

Specifies the event type, behavior, and contextual information to be used in processing the event.

Returns

bool

The return value of Aspose.Html.Dom.EventTarget.DispatchEvent(Aspose.Html.Dom.Events.Event) indicates whether any of the listeners which handled the event called Aspose.Html.Dom.Events.Event.PreventDefault. If Aspose.Html.Dom.Events.Event.PreventDefault was called the value is false, else the value is true.

Remarks

Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the Aspose.Html.Dom.EventTarget on which Aspose.Html.Dom.EventTarget.DispatchEvent(Aspose.Html.Dom.Events.Event) is called.

Exceptions

DOMException

RemoveEventListener(string, IEventListener)

This method allows the removal of event listeners from the event target. If an Aspose.Html.Dom.Events.IEventListener is removed from an Aspose.Html.Dom.EventTarget while it is processing an event, it will not be triggered by the current actions. Event Listeners can never be invoked after being removed.

[DOMName("removeEventListener")]
void RemoveEventListener(string type, IEventListener listener)

Parameters

type string

Specifies the event type of the Aspose.Html.Dom.Events.IEventListener being removed.

listener IEventListener

The Aspose.Html.Dom.Events.IEventListener parameter indicates the Aspose.Html.Dom.Events.IEventListener to be removed.

RemoveEventListener(string, IEventListener, bool)

This method allows the removal of event listeners from the event target. If an Aspose.Html.Dom.Events.IEventListener is removed from an Aspose.Html.Dom.EventTarget while it is processing an event, it will not be triggered by the current actions. Event Listeners can never be invoked after being removed.

[DOMName("removeEventListener")]
void RemoveEventListener(string type, IEventListener listener, bool useCapture)

Parameters

type string

Specifies the event type of the Aspose.Html.Dom.Events.IEventListener being removed.

listener IEventListener

The Aspose.Html.Dom.Events.IEventListener parameter indicates the Aspose.Html.Dom.Events.IEventListener to be removed.

useCapture bool

Specifies whether the EventListener being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.