Cefsharp Oncontextmenucommand获取菜单标签

时间:2018-03-13 08:50:36

标签: c# .net vb.net winforms cefsharp

好的,所以我在我的程序中有这个代码,在上下文菜单中添加菜单项,并在点击它们时执行操作

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

如何获取单击的菜单项(在Oncontextmenucommand函数中)的标签?如何访问IMenuModel,因为它具有getlabel函数。

此致

0 个答案:

没有答案