Class CustomEvent
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The CustomEvent interface can be used to attach custom data to an event generated by an application.
[Value("CustomEvent")]
public class CustomEvent : Event
- Inheritance
-
CustomEvent
- Inherited Members
Remarks
As an alternative to CustomEvent, you can subclass the Event interface to add custom data and behavior.
NOTE
If used to attempt to communicate between a web extension content script and a web page script, a non-string
detailproperty throws with "Permission denied to access property" in Firefox. To avoid this issue clone the object. See Share objects with page scripts for more information.
-PostMessage(dynamic, string, List<Object>)
-Creating and dispatching events
Constructors
CustomEvent()
public CustomEvent()
CustomEvent(string, CustomEventInit)
The CustomEvent() constructor creates a new CustomEvent object.
public CustomEvent(string type, CustomEventInit eventInitDict = null)
Parameters
typestringeventInitDictCustomEventInit
Remarks
Properties
Detail
The read-only detail property of the CustomEvent interface returns any data passed when initializing the event.
[Value("detail")]
public dynamic Detail { get; }
Property Value
- dynamic
Whatever data the event was initialized with.
Remarks
Methods
InitCustomEvent(string, bool, bool, dynamic)
IMPORTANT
DeprecatedCustomEvent.initCustomEvent() method initializes a CustomEvent object.If the event has already been dispatched, this method does nothing.
[Value("initCustomEvent")]
public GlobalObject.Undefined InitCustomEvent(string type, bool bubbles = false, bool cancelable = false, dynamic detail = null)
Parameters
Returns
- GlobalObject.Undefined
None (
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.
NOTE
Do not use this method anymore, as it is deprecated.
Rather than using the feature, instead use specific event constructors, like CustomEvent(string, CustomEventInit).
The section on Creating and dispatching events gives more information about the way to use those.
-CustomEvent
-The constructor to use instead of this deprecated method: CustomEvent(string, CustomEventInit).