Event Class

https://dom.spec.whatwg.org/#interface-event

public class Event

Constructors

NameDescription
Event(string, EventInit?)https://dom.spec.whatwg.org/#dom-event-event

Event(string, EventInit?)

Event.cs

https://dom.spec.whatwg.org/#dom-event-event

public Event(string type, EventInit? eventInitDict = null)

Properties

NameDescription
BubblesGets a value indicating whether the event bubbles up through the tree.
CancelBubbleGets or sets the legacy stop propagation flag; setting it to true stops the propagation of the event.
CancelableGets a value indicating whether the event can be canceled with preventDefault().
ComposedGets a value indicating whether the event propagates across the shadow DOM boundary.
CurrentTargetGets the object whose listener is currently being invoked.
DefaultPreventedGets a value indicating whether the event has been canceled.
EventPhaseGets the current phase of the event dispatch (NONE, CAPTURING_PHASE, AT_TARGET or BUBBLING_PHASE).
IsTrustedGets a value indicating whether the event was dispatched by the user agent rather than created by a script.
ReturnValueGets or sets the legacy inverse of defaultPrevented; setting it to false cancels the event.
SrcElementGets the object the event was dispatched to (legacy alias of target).
TargetGets the object the event was dispatched to.
TimeStampThe time the event was created, in milliseconds relative to the time origin.
TypeGets the type of the event, such as click.

Bubbles

Event.cs

Gets a value indicating whether the event bubbles up through the tree.

public bool Bubbles { get; }

CancelBubble

Event.cs

Gets or sets the legacy stop propagation flag; setting it to true stops the propagation of the event.

public bool CancelBubble { get; set; }

Cancelable

Event.cs

Gets a value indicating whether the event can be canceled with preventDefault().

public bool Cancelable { get; }

Composed

Event.cs

Gets a value indicating whether the event propagates across the shadow DOM boundary.

public bool Composed { get; }

CurrentTarget

Event.cs

Gets the object whose listener is currently being invoked.

public EventTarget? CurrentTarget { get; }

DefaultPrevented

Event.cs

Gets a value indicating whether the event has been canceled.

public bool DefaultPrevented { get; }

EventPhase

Event.cs

Gets the current phase of the event dispatch (NONE, CAPTURING_PHASE, AT_TARGET or BUBBLING_PHASE).

public ushort EventPhase { get; }

IsTrusted

Event.cs

Gets a value indicating whether the event was dispatched by the user agent rather than created by a script.

public bool IsTrusted { get; }

ReturnValue

Event.cs

Gets or sets the legacy inverse of defaultPrevented; setting it to false cancels the event.

public bool ReturnValue { get; set; }

SrcElement

Event.cs

Gets the object the event was dispatched to (legacy alias of target).

public EventTarget? SrcElement { get; }

Target

Event.cs

Gets the object the event was dispatched to.

public EventTarget? Target { get; }

TimeStamp

Event.cs

The time the event was created, in milliseconds relative to the time origin.

public double TimeStamp { get; }

Gets the type of the event, such as click.

public string Type { get; }

Methods

NameDescription
ComposedPath()https://dom.spec.whatwg.org/#dom-event-composedpath
InitEvent(string, bool, bool)https://dom.spec.whatwg.org/#dom-event-initevent
PreventDefault()Cancels the event when it is cancelable.
StopImmediatePropagation()Prevents the event from reaching the other listeners, including the remaining listeners of the current target.
StopPropagation()Prevents the event from reaching the listeners of the other objects of its path.

ComposedPath()

Event.cs

https://dom.spec.whatwg.org/#dom-event-composedpath

public IReadOnlyList<EventTarget> ComposedPath()

InitEvent(string, bool, bool)

Event.cs

https://dom.spec.whatwg.org/#dom-event-initevent

public void InitEvent(string type, bool bubbles = false, bool cancelable = false)

Parameters

type string
bubbles bool
cancelable bool

See also

PreventDefault()

Event.cs

Cancels the event when it is cancelable.

public void PreventDefault()

StopImmediatePropagation()

Event.cs

Prevents the event from reaching the other listeners, including the remaining listeners of the current target.

public void StopImmediatePropagation()

StopPropagation()

Event.cs

Prevents the event from reaching the listeners of the other objects of its path.

public void StopPropagation()

Constants

NameDescription
AtTargetThe event has reached its target.
BubblingPhaseThe event is propagating back up through the ancestors of the target.
CapturingPhaseThe event is propagating through the ancestors of the target, from the root.
NoneThe event is not being dispatched.

AtTarget

The event has reached its target.

public const ushort AtTarget = 2

BubblingPhase

The event is propagating back up through the ancestors of the target.

public const ushort BubblingPhase = 3

CapturingPhase

The event is propagating through the ancestors of the target, from the root.

public const ushort CapturingPhase = 1

None

The event is not being dispatched.

public const ushort None = 0