mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / DispatchEvent Method

CSS3 Selector of the Event Target HTML5 Element.

If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.

The name of the Event.

Set True for Event Bubbling.

Set True if Event can be cancelled.

Set True if Event is Composed.

Event Data passed as OLE/COM Variant which is converted to V8 JavaScript Value.

If True then the event cannot be cancelled which results in better performance between the ActiveX and Chromium engine.

This affects the Interprocess Communication Protocol between the ActiveX and Chromium. Read remarks section for more information.

In This Topic
    DispatchEvent Method
    In This Topic
    Description

    Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order.

    Syntax
    Visual Basic
    Public Function DispatchEvent( _
       ByVal TargetSelector As String, _
       ByVal EventName As String, _
       ByVal Bubbles As Boolean, _
       ByVal Cancelable As Boolean, _
       ByVal Composed As Boolean, _
       ByVal Detail As Variant, _
       ByVal ImmutableEvent As Boolean _
    ) As Variant
    Parameters
    TargetSelector

    CSS3 Selector of the Event Target HTML5 Element.

    If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.

    EventName

    The name of the Event.

    Bubbles

    Set True for Event Bubbling.

    Cancelable

    Set True if Event can be cancelled.

    Composed

    Set True if Event is Composed.

    Detail

    Event Data passed as OLE/COM Variant which is converted to V8 JavaScript Value.

    ImmutableEvent

    If True then the event cannot be cancelled which results in better performance between the ActiveX and Chromium engine.

    This affects the Interprocess Communication Protocol between the ActiveX and Chromium. Read remarks section for more information.

    Return Type

    Result of JavaScript Event Handler.

    Remarks

    WebKitX DispatchEvent() method allows you to fire DOM events directly into HTML5 and handle those events by JavaScript event handlers. You can pass the target selector that will receive the event, the event name, event initialization parameters (bubbling, cancelable, composed) and an OLE/COM Variant that will be converted into a V8 JavaScript object and added in the details field of the Event object. Event execution can be both synchronous and asynchronous in terms of IPC tunneling, and it is always synchronous in terms of DOM.

    Dispatch Event Circuit

    Dispatch Event Circuit

     

    Unlike "native" events, which are fired by the DOM and invoke event handlers asynchronously via the event loop, dispatchEvent invokes event handlers synchronously. All applicable event handlers will execute and return before the code continues on after the call to dispatchEvent.

    The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

    JavaScript Event Handler for DispatchEvent

    JavaScript Event Handler for DispatchEvent

    Example
    Private Sub mnuTestDispatchEvent_Click()
        On Error Resume Next
        Dim s As String
        Dim result As Boolean
        s = InputBox("Selector", , "body")
        If s = "" Then Exit Sub
        result = WebKitX1.DispatchEvent(s, "my_event", True, True, True, Array("My Data", 10, 3.14, Date + Time), True)
        MsgBox result, vbInformation
    End Sub
    private void menuItemTestDispatchEvent_Click(object sender, EventArgs e)
    {
        string input = Microsoft.VisualBasic.Interaction.InputBox("Selector", "HTML5 Pad", "Body", 500, 300);            
        if (input != "")
        {
            object result = WebKitXCEF31.DispatchEvent(input, "my_event", true, true, true, new object[] { "My Data", 10, "3.14" }, true);
            MessageBox.Show(result.ToString(), "HTML5 Pad", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
    See Also