mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / ExecCommandSetFocus Property
In This Topic
    ExecCommandSetFocus Property
    In This Topic
    This master flag enables or disables setting focus to the control after ExecCommand is executed.
    Property type
    Read-write property
    Visual Basic
    Public Property ExecCommandSetFocus As Boolean
    Return Type

    Returns current property value.


    Setting this flag to True is quite useful for applications that implement HTML5 Editing. Typically a modern HTML5 Editor would have a Toolbar-based UI with functions such as text formatting and styling, inserting or deleting DOM elements, etc. When you click on your app's Toolbar the control loses focus and by setting this flag to True it helps the control regain focus after a styling command has been applied.

    • In the example below, WebKitX control has focus and some selection.
    • When the user clicks on a Formatting Toolbar Button, WebKitX control loses focus and focus is set to the Formatting Toolbar.
    • Assuming the user clicked on Bold Toolbar Button, the event handler would probably call the WebKitX ExecCommand(EDIT_CMD_BOLD) method.
    • If the user tries to continue editing, eg. type any text, it be ignored by WebKitX, since the focused control is now the Toolbar.
    • By setting ExecCommandSetFocus to True, after the ExecCommand(EDIT_CMD_BOLD) is executed, WebKitX control will regain focus.
    Private Sub WebKitX1_OnBrowserReady()
        On Error Resume Next
        ' Restore focus to WebKitX after a command is executed (form a menu or context menu)
        WebKitX1.ExecCommandSetFocus = True
        ' Enable mobileFX formatting vs. CEF3 formatting (Recommended)
        WebKitX1.FormatUsingInternalSelectionAPI = True
        ' Allow JavaScript download (sometimes scripts such as parallax mess with HTML5 styles)
        WebKitX1.DownloadScripts = False
        mnuDownloadScripts.Checked = False
        ' Initial HTML to show (optional)
        If LoadFile <> "" Then
            WebKitX1.Open LoadFile
            LoadFile = ""
            WebKitX1.HTML = "<html><body></body></html>"
        End If
        'WebKitX1.Open "file:///my_path/index.html"
    End Sub
    private void WebKitXCEF31_OnBrowserReady(object sender, EventArgs e)
        WebKitXCEF31.ExecCommandSetFocus = true;
        WebKitXCEF31.FormatUsingInternalSelectionAPI = true;
        WebKitXCEF31.DownloadScripts = false;
        menuItemDownloadScript.Checked = false;
        if (LoadFile != "")
            LoadFile = "";
            WebKitXCEF31.HTML = "<html><body></body></html>";
    See Also