You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Namespace:SpawnDev.SpawnJS.JSObjects Inheritance: SpawnJSObject -> Event MDN Reference:Event on MDN Source:SpawnDev.SpawnJS/JSObjects/DOM/Event.cs
The Event interface represents an event which takes place on an EventTarget. It is the base class for all event types in SpawnDev.SpawnJS - MouseEvent, KeyboardEvent, TouchEvent, CustomEvent, etc. all inherit from Event. It provides common properties like type, target, and bubbling behavior, plus methods for controlling event propagation.
Constructor
// From existing reference (deserialization)publicEvent(SpawnJSObjectReference _ref)
Properties
Property
Type
Description
Type
string
The name of the event (e.g., "click", "keydown", "resize").
Target
EventTarget
The original target that dispatched the event.
CurrentTarget
EventTarget?
The target currently processing the event (during bubbling/capture).
EventPhase
int
The phase of the event flow: 0=NONE, 1=CAPTURING, 2=AT_TARGET, 3=BUBBLING.
Bubbles
bool
Whether the event bubbles up through the DOM.
Cancelable
bool
Whether the event can be cancelled via preventDefault().
DefaultPrevented
bool
Whether preventDefault() was called.
Composed
bool
Whether the event can cross shadow DOM boundaries.
IsTrusted
bool
True if the event was initiated by the browser (not by script).
TimeStamp
double
The time the event was created (milliseconds).
Typed Target Accessors
Method
Return Type
Description
TargetAs<T>()
T
Get Target cast to a specific EventTarget subclass.
CurrentTargetAs<T>()
T
Get CurrentTarget cast to a specific EventTarget subclass.
Methods
Method
Return Type
Description
PreventDefault()
void
Cancel the event's default action (if cancelable).
StopPropagation()
void
Stop the event from propagating to parent elements. Does not prevent other listeners on the current element.
StopImmediatePropagation()
void
Stop propagation AND prevent remaining listeners on the current element from being called.
ComposedPath()
Array<EventTarget>
Get the event's propagation path (array of EventTargets).
Overrides the Target property to return the specific target type directly.
Property
Type
Description
Target
TTarget
The event target, strongly typed.
Example
voidHandleClick(Evente){Console.WriteLine($"Event type: {e.Type}");// "click"Console.WriteLine($"Bubbles: {e.Bubbles}");// trueConsole.WriteLine($"Trusted: {e.IsTrusted}");// true (if user-initiated)Console.WriteLine($"Timestamp: {e.TimeStamp}ms");// Get target as specific typeusingvartarget=e.TargetAs<HTMLElement>();Console.WriteLine($"Target tag: {target.TagName}");// Cancel default behaviorif(e.Cancelable){e.PreventDefault();}// Stop bubblinge.StopPropagation();}element.OnClick+=HandleClick;
Example - Event<TTarget>
// When the target type is knownvoidHandleInput(Event<HTMLInputElement>e){// Target is already typed - no casting neededstringvalue=e.Target.Value;Console.WriteLine($"Input value: {value}");}