Compartilhar via


interface ICoreWebView2ContextMenuItem

interface ICoreWebView2ContextMenuItem
  : public IUnknown

Represents a context menu item of a context menu displayed by WebView.

Summary

Members Descriptions
add_CustomItemSelected Add an event handler for the CustomItemSelected event.
get_Children Gets the list of children menu items through a ContextMenuItemCollection if the kind is Submenu.
get_CommandId Gets the Command ID for the ContextMenuItem.
get_Icon Gets the Icon for the ContextMenuItem in PNG, Bitmap or SVG formats in the form of an IStream.
get_IsChecked Gets the checked property of the ContextMenuItem, used if the kind is Check box or Radio.
get_IsEnabled Gets the enabled property of the ContextMenuItem.
get_Kind Gets the ContextMenuItem kind.
get_Label Gets the localized label for the ContextMenuItem.
get_Name Gets the unlocalized name for the ContextMenuItem.
get_ShortcutKeyDescription Gets the localized keyboard shortcut for this ContextMenuItem.
put_IsChecked Sets the checked property of the ContextMenuItem.
put_IsEnabled Sets the enabled property of the ContextMenuItem.
remove_CustomItemSelected Remove an event handler previously added with add_CustomItemSelected.

Applies to

Product Introduced
WebView2 Win32 1.0.1185.39
WebView2 Win32 Prerelease 1.0.1189

Members

add_CustomItemSelected

Add an event handler for the CustomItemSelected event.

public HRESULT add_CustomItemSelected(ICoreWebView2CustomItemSelectedEventHandler * eventHandler, EventRegistrationToken * token)

CustomItemSelected event is raised when the user selects this ContextMenuItem. Will only be raised for end developer created context menu items

get_Children

Gets the list of children menu items through a ContextMenuItemCollection if the kind is Submenu.

public HRESULT get_Children(ICoreWebView2ContextMenuItemCollection ** value)

If the kind is not submenu, will return null.

get_CommandId

Gets the Command ID for the ContextMenuItem.

public HRESULT get_CommandId(INT32 * value)

Use this to report the SelectedCommandId in ContextMenuRequested event.

get_Icon

Gets the Icon for the ContextMenuItem in PNG, Bitmap or SVG formats in the form of an IStream.

public HRESULT get_Icon(IStream ** value)

Stream will be rewound to the start of the image data.

get_IsChecked

Gets the checked property of the ContextMenuItem, used if the kind is Check box or Radio.

public HRESULT get_IsChecked(BOOL * value)

get_IsEnabled

Gets the enabled property of the ContextMenuItem.

public HRESULT get_IsEnabled(BOOL * value)

get_Kind

Gets the ContextMenuItem kind.

public HRESULT get_Kind(COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND * value)

get_Label

Gets the localized label for the ContextMenuItem.

public HRESULT get_Label(LPWSTR * value)

Will contain an ampersand for characters to be used as keyboard accelerator.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_Name

Gets the unlocalized name for the ContextMenuItem.

public HRESULT get_Name(LPWSTR * value)

Use this to distinguish between context menu item types. This will be the English label of the menu item in lower camel case. For example, the "Save as" menu item will be "saveAs". Extension menu items will be "extension", custom menu items will be "custom" and spellcheck items will be "spellCheck". Some example context menu item names are:

  • "saveAs"

  • "copyImage"

  • "openLinkInNewWindow"

  • "cut"

  • "copy"

  • "paste"

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_ShortcutKeyDescription

Gets the localized keyboard shortcut for this ContextMenuItem.

public HRESULT get_ShortcutKeyDescription(LPWSTR * value)

It will be the empty string if there is no keyboard shortcut. This is text intended to be displayed to the end user to show the keyboard shortcut. For example this property is Ctrl+Shift+I for the "Inspect" ContextMenuItem.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

put_IsChecked

Sets the checked property of the ContextMenuItem.

public HRESULT put_IsChecked(BOOL value)

Must only be used for custom context menu items that are of kind Check box or Radio.

put_IsEnabled

Sets the enabled property of the ContextMenuItem.

public HRESULT put_IsEnabled(BOOL value)

Must only be used in the case of a custom context menu item. The default value for this is TRUE.

remove_CustomItemSelected

Remove an event handler previously added with add_CustomItemSelected.

public HRESULT remove_CustomItemSelected(EventRegistrationToken token)