mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / OnEvent Event

The name of the event.

The internal CSS3 selector of the event. 

This is window or document for events set by Events property or the actual CSS3 selector for events set with AddEventListener and AddEventListenerEx.

The CSS3 selector of the target HTML5 Element that dispatched the event.

A back-slash separated path of Tag Name [ CSS3 Selector ] patterns, starting from the <BODY> element up to the target HTML5 Element that dispatched the event.

String
Copy Code
BODY[body]/DIV[div.section]/P[p:nth-child(3)]/SPAN[p:nth-of-type(1) > span:nth-child(2)]

The event data in JSON Stringified format:

JSON
Copy Code
{
  "eventName": "DOMFocusIn",
  "eventType": "[object FocusEvent]",
  "bubbles": true,
  "cancelBubble": false,
  "cancelable": false,
  "composed": true,
  "currentTarget": "",
  "defaultPrevented": false,
  "detail": 0,
  "eventPhase": 1,
  "fromElement": "",
  "isTrusted": true,
  "originalTarget": "",
  "path": "body",
  "relatedTarget": "",
  "returnValue": true,
  "srcElement": "body",
  "sourceCapabilities": null,
  "target": "body",
  "timeStamp": 899.6000000006461,
  "toElement": "",
  "type": "DOMFocusIn",
  "view": "[object Window]",
  "which": 0,
  "NONE": 0,
  "CAPTURING_PHASE": 1,
  "AT_TARGET": 2,
  "BUBBLING_PHASE": 3
}

 

Indicates if this is a synchronous or asynchronous event.

For synchronous events only, you can set this argument to True to cancel the event and prevent its default behavior.

For synchronous events only, you can set this argument to True to cancel the event bubbling.

OnEvent Event
Description

Fired when an HTML5 DOM Event occurs. This is generic event handler that provides fast event handling for various events.

Syntax
Visual Basic
Public Event OnEvent( _
   ByVal EventType As String, _
   ByVal EventSelector As String, _
   ByVal TargetSelector As String, _
   ByVal TargetPath As String, _
   ByVal EventData As String, _
   ByVal Async As Boolean, _
   ByRef PreventDefault As Boolean, _
   ByRef CancelBubble As Boolean _
)
Parameters
EventType

The name of the event.

EventSelector

The internal CSS3 selector of the event. 

This is window or document for events set by Events property or the actual CSS3 selector for events set with AddEventListener and AddEventListenerEx.

TargetSelector

The CSS3 selector of the target HTML5 Element that dispatched the event.

TargetPath

A back-slash separated path of Tag Name [ CSS3 Selector ] patterns, starting from the <BODY> element up to the target HTML5 Element that dispatched the event.

String
Copy Code
BODY[body]/DIV[div.section]/P[p:nth-child(3)]/SPAN[p:nth-of-type(1) > span:nth-child(2)]
EventData

The event data in JSON Stringified format:

JSON
Copy Code
{
  "eventName": "DOMFocusIn",
  "eventType": "[object FocusEvent]",
  "bubbles": true,
  "cancelBubble": false,
  "cancelable": false,
  "composed": true,
  "currentTarget": "",
  "defaultPrevented": false,
  "detail": 0,
  "eventPhase": 1,
  "fromElement": "",
  "isTrusted": true,
  "originalTarget": "",
  "path": "body",
  "relatedTarget": "",
  "returnValue": true,
  "srcElement": "body",
  "sourceCapabilities": null,
  "target": "body",
  "timeStamp": 899.6000000006461,
  "toElement": "",
  "type": "DOMFocusIn",
  "view": "[object Window]",
  "which": 0,
  "NONE": 0,
  "CAPTURING_PHASE": 1,
  "AT_TARGET": 2,
  "BUBBLING_PHASE": 3
}

 

Async

Indicates if this is a synchronous or asynchronous event.

PreventDefault

For synchronous events only, you can set this argument to True to cancel the event and prevent its default behavior.

CancelBubble

For synchronous events only, you can set this argument to True to cancel the event bubbling.

Remarks

Setting OnEvent

There are two ways to enable receiving HTML5 DOM events through OnEvent:

Asynchronous DOM to COM Events

Image Title

Image Title

HTML5 DOM Events are generated by WebKit Blink Engine and are copied into an immutable format before they are transmitted from CEFXClient process to WebKitX ActiveX. Once WebKitX ActiveX receives an event notification through IPC, it fires a COM Event with the copied data of HTML DOM event. Thus, CEFXClient process does not block waiting for your client code to handle the event. WebKitX DOM Events are Immutable, meaning that you can only read event data but you cannot cancel events, stop them from bubbling or prevent default behavior.

Synchronous DOM to COM Events

Image Title

Image Title

WebKitX as of version 1.5.11.2591 supports synchronous DOM to COM events by implementing CefMessageRouter circuit. Events generated from WebKit Blink Engine are serialized and passed from Rendering to Browser process, which transmits them to the ActiveX. The browser process waits for the ActiveX to handle the event, where you can also cancel event bubble or prevent event's default behavior.

Please note that blocking Inter-process Communication (IPC) between 3 processes is not advisable for casual event handling and you should do so only if you need to cancel specific events. Synchronous DOM to COM Events are thread-safe and care has been placed in order to support this feature seamlessly in single-threaded Applications without deadlocks. For that purpose, synchronous events are serialized using mutex synchronization on entry, meaning that synchronous events occupy the IPC channel one at a time. Please contact us for more implementation details or if you need a different handling of DOM to COM events.

Example
Private Sub WebKitX1_OnEvent(ByVal EventType As String, ByVal EventSelector As String, ByVal TargetSelector As String, ByVal TargetPath As String, ByVal EventData As String, ByVal Async As Boolean, PreventDefault As Boolean, CancelBubble As Boolean)

    On Error Resume Next
    
    If NoEvents Then Exit Sub
    
    Select Case EventType
    
    Case "input"
    
        WebKitX1.Modified = True
    
    Case "click"
        
        If EditMode <> EDIT_DESIGNER Then
            EditMode = EDIT_DESIGNER
            Timer1.Enabled = True
        End If
    
    Case "selectstart", "DOMFocusIn" 'DOMFocusIn for IMG
    
        picStatus.Cls
        picStatus.CurrentX = 4
        picStatus.CurrentY = 2
        picStatus.Print TargetSelector
    
        Dim v As Variant
        Dim i As Long
        Dim b As Button
        Dim s As String
        Dim k As String
        Dim p As Long
        Dim m As ButtonMenu
        Dim tag As String
        
        Toolbar2.Buttons.Clear
        
        Debug.Print TargetPath
        
        v = Split(TargetPath, "/")
        For i = 0 To UBound(v)
            p = InStr(v(i), "[")
            tag = Left(v(i), p - 1)
            s = "<" + tag + ">"
            k = Mid(v(i), p + 1)
            k = Left(k, Len(k) - 1)
            Set b = Toolbar2.Buttons.Add(, k, s)
            b.ToolTipText = k
            b.Style = tbrDropdown
            b.ButtonMenus.Add , , "Select Node"
            b.ButtonMenus.Add , , "Select Contents"
            b.ButtonMenus.Add , , "-"
            b.ButtonMenus.Add , , "Cut"
            b.ButtonMenus.Add , , "Copy"
            b.ButtonMenus.Add , , "Delete"
            b.ButtonMenus.Add , , "-"
            b.ButtonMenus.Add , , "Edit InnerHTML ..."
            b.ButtonMenus.Add , , "Edit OuterHTML ..."
            b.ButtonMenus.Add , , "-"
            b.ButtonMenus.Add , , "Set Class ..."
            b.ButtonMenus.Add , , "Edit Style ..."
            b.ButtonMenus.Add , , "Get Computed Style"
            b.ButtonMenus.Add , , "-"
            b.ButtonMenus.Add , , "Edit Attributes ..."
            b.ButtonMenus.Add , , "-"
            b.ButtonMenus.Add , , "Copy Selector"
            
            Select Case tag
            
            Case "A"
                b.ButtonMenus.Add , , "-"
                b.ButtonMenus.Add , , "Edit Hyperlink ..."
            
            Case "TABLE"
                b.ButtonMenus.Add , , "-"
                b.ButtonMenus.Add , , "Edit Table ..."
            
            Case "TD"
                b.ButtonMenus.Add , , "-"
                b.ButtonMenus.Add , , "Select Column"
            
            Case "HR"
                b.ButtonMenus.Add , , "-"
                b.ButtonMenus.Add , , "Edit Horizontal Line ..."
                
            Case "IMG"
                b.ButtonMenus.Add , , "-"
                b.ButtonMenus.Add , , "Edit Image ..."
                
            Case "VIDEO"
                b.ButtonMenus.Add , , "-"
                b.ButtonMenus.Add , , "Edit Image ..."
                
            Case "FORM"
                b.ButtonMenus.Add , , "-"
                b.ButtonMenus.Add , , "Edit Form ..."
                
            Case "INPUT", "SELECT"
                b.ButtonMenus.Add , , "-"
                b.ButtonMenus.Add , , "Edit Control ..."
                
            End Select
            
            If i = UBound(v) Then
                CurrentSelector = k
            End If
        Next
        
    Case "DOMSubtreeModified"
        
        If InStr(TargetPath, "html.windows.chrome") > 0 Then Exit Sub
        If NoDomModifications Then Exit Sub
        If EditMode = EDIT_SOURCE Then Exit Sub
        Timer1.Enabled = False
        Timer1.Enabled = True
        
    Case Else
    
        AddLog "OnEvent: EventType=" & EventType & ", EventSelector=" & EventSelector & ", TargetSelector=" & TargetSelector & " TargetPath=" & TargetPath & ", EventData=" & EventData
    
    End Select
        
End Sub
See Also