Cefsharp Oncontextmenucommand Get Menu Label

房东的猫 提交于 2020-04-17 22:05:56

问题


Alright so I have this code in my program to add menu items in context menu and perform action when they are clicked

Private Sub IContextMenuHandler_OnBeforeContextMenu(browserControl As IWebBrowser, browser As IBrowser, frame As IFrame, parameters As IContextMenuParams, model As IMenuModel) Implements IContextMenuHandler.OnBeforeContextMenu
    ''Add new custom menu items
    model.AddItem(DirectCast(Copy, CefMenuCommand), "Copy Link Address")
    model.AddItem(CType(26504, CefMenuCommand), "Display alert message")

    Dim viewMenu As IMenuModel = model.AddSubMenu(CType(26505, CefMenuCommand), "View")
    viewMenu.AddRadioItem(CType(26506, CefMenuCommand), "Large icons", 0)
    viewMenu.AddRadioItem(CType(26507, CefMenuCommand), "Medium icons", 0)
    viewMenu.AddRadioItem(CType(26508, CefMenuCommand), "Small icons", 0)
    viewMenu.AddSeparator()

End Sub

Private Function IContextMenuHandler_OnContextMenuCommand(browserControl As IWebBrowser, browser As IBrowser, frame As IFrame, parameters As IContextMenuParams, commandId As CefMenuCommand, eventFlags As CefEventFlags) As Boolean Implements IContextMenuHandler.OnContextMenuCommand
    Try
        If CInt(commandId) = Copy Then
            If (parameters.LinkUrl.Length > 0) Then
                Clipboard.SetText(parameters.LinkUrl)
            End If
        End If

        If commandId = CType(26504, CefMenuCommand) Then
            Clipboard.SetText(imn.GetLabel(CType(26504, CefMenuCommand)))
            browserControl.Paste()
        End If
    Catch ex As Exception
        ''MsgBox(ex.Message)
    End Try

    Return False
End Function

How do I get the label of the menu item (in Oncontextmenucommand function) which was clicked ? How do I access the IMenuModel because it has a getlabel function.

Regards,

来源:https://stackoverflow.com/questions/49251796/cefsharp-oncontextmenucommand-get-menu-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!