Table of Contents

Class UIEvent

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The UIEvent interface represents simple user interface events. It is part of the UI Events API, which includes various event types and interfaces related to user interactions.

[Value("UIEvent")]
public class UIEvent : Event
Inheritance
UIEvent
Derived
Inherited Members

Remarks

UIEvent derives from Event. Although the InitUIEvent(string, bool, bool, Window?, long) method is kept for backward compatibility, you should create a UIEvent object using the UIEvent(string, UIEventInit) constructor.

Several interfaces are direct or indirect descendants of this one: MouseEvent, TouchEvent, FocusEvent, KeyboardEvent, WheelEvent, InputEvent, and CompositionEvent.

-UI Events API
-Introduction to events
-Event

See also on MDN

Constructors

UIEvent()

public UIEvent()

UIEvent(string, UIEventInit)

The UIEvent() constructor creates a new UIEvent object.

public UIEvent(string type, UIEventInit eventInitDict = null)

Parameters

type string
eventInitDict UIEventInit

Remarks

NOTE

If you construct a synthetic event using this constructor, that event will not be trusted, for security reasons.
Only browser-generated UIEvent objects are trusted and only trusted events trigger default actions.

-UIEvent, the interface of the objects it constructs.

See also on MDN

Properties

Detail

The UIEvent.detail read-only property, when non-zero, provides the current (or next, depending on the event) click count.

[Value("detail")]
public long Detail { get; }

Property Value

long

Remarks

For Elementclick or Elementdblclick events, UIEvent.detail is the current click count.

For Elementmousedown or Elementmouseup events, UIEvent.detail is 1 plus the current click count.

For all other UIEvent objects, UIEvent.detail is always zero.

See also on MDN

SourceCapabilities

NOTE
Experimental
The sourceCapabilities read-only property of the UIEvent interface returns
an instance of the 'InputDeviceCapabilities' interface which provides
information about the physical device responsible for generating a touch event. If no
input device was responsible for the event, it returns null.
[Value("sourceCapabilities")]
public InputDeviceCapabilities? SourceCapabilities { get; }

Property Value

InputDeviceCapabilities

An instance of 'InputDeviceCapabilities'.

Remarks

When a single user interaction with an input device generates a series of different
input events, the sourceCapabilities property for all of them will point to
the same instance of InputDeviceCapabilities. For example, when a user
lifts their finger off of a touchscreen, several UIEvents may be generated including
touchend, mousedown, click, and
focus. All of these events must have the same
sourceCapabilities representing the touchscreen.

A device is considered "responsible" for an event only when that interaction is part of
the abstraction provided by the web platform. For example, many user agents allow a
window to be resized with a mouse or a keyboard, but this detail is not exposed to the
web platform in any way, and so the sourceCapabilities of a resize event will typically
be null.

See also on MDN

View

The UIEvent.view read-only property returns the
WindowProxy object from which the event was generated. In browsers, this
is the Window object the event happened in.

[Value("view")]
public Window? View { get; }

Property Value

Window

A reference to an AbstractView object.

Remarks

Which

IMPORTANT
Deprecated
The UIEvent.which read-only property of the UIEvent interface returns a number that indicates which button was pressed on the mouse, or the numeric keyCode or the character code (charCode) of the key pressed on the keyboard.
[Value("which")]
public ulong Which { get; }

Property Value

ulong

For KeyboardEvent, event.which contains the numeric code for a particular key pressed, depending on whether an alphanumeric or non-alphanumeric key was pressed.
Please see deprecated CharCode and KeyCode for more details.

NOTE
Consider Key or Code for new code.
For MouseEvent, event.which is a number representing a given button:For a mouse configured for left-handed use, the button actions are reversed.
In this case, the values are read from right to left.
NOTE
Consider Button for new code.

Remarks

Methods

InitUIEvent(string, bool, bool, Window?, long)

IMPORTANT
Deprecated
The UIEvent.initUIEvent() method initializes a UI event
once it's been created.
[Value("initUIEvent")]
public GlobalObject.Undefined InitUIEvent(string typeArg, bool bubblesArg = false, bool cancelableArg = false, Window? viewArg = null, long detailArg = 0)

Parameters

typeArg string
bubblesArg bool
cancelableArg bool
viewArg Window
detailArg long

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Events initialized in this way must have been created with the CreateEvent(string) method. This method must be called to set the event
before it is dispatched, using DispatchEvent(Event). Once
dispatched, it doesn't do anything anymore.

WARNING

Do not use this method anymore as it is deprecated.

Instead use specific event constructors, like UIEvent(string, UIEventInit). The page on Creating and dispatching events gives more information about the way to use these.

-UIEvent
-The constructor to use instead of this deprecated method:
UIEvent(string, UIEventInit). More specific constructors can be used
too.

See also on MDN