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.
Constructors
UIEvent()
public UIEvent()
UIEvent(string, UIEventInit)
The UIEvent() constructor creates a new UIEvent object.
public UIEvent(string type, UIEventInit eventInitDict = null)
Parameters
typestringeventInitDictUIEventInit
Remarks
NOTE
If you construct a synthetic event using this constructor, that event will not be trusted, for security reasons.
Only browser-generatedUIEventobjects are trusted and only trusted events trigger default actions.
-UIEvent, the interface of the objects it constructs.
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
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.
SourceCapabilities
NOTE
ExperimentalsourceCapabilities read-only property of the UIEvent interface returnsan 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 includingtouchend, mousedown, click, andfocus. All of these events must have the samesourceCapabilities 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.
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
AbstractViewobject.
Remarks
Which
IMPORTANT
DeprecatedUIEvent.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.whichcontains 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.
For MouseEvent,NOTE
Consider Key or Code for new code.event.whichis 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
DeprecatedUIEvent.initUIEvent() method initializes a UI eventonce 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
Returns
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.