interface ICoreWebView2ExperimentalContextMenuRequestedEventArgs

Note

This an experimental API that is shipped with our prerelease SDK. See WebView2 release notes.

interface ICoreWebView2ExperimentalContextMenuRequestedEventArgs
  : public IUnknown

Event args for the ContextMenuRequested event.

Summary

Members Descriptions
get_ContextMenuTarget Gets the target information associated with the requested context menu.
get_Handled Gets whether the ContextMenuRequested event is handled by host.
get_Location Gets the coordinates where the context menu request occurred in relation to the upper left corner of the WebView bounds.
get_MenuItems Gets the collection of ContextMenuItem objects.
get_SelectedCommandId Gets the selected CommandId.
GetDeferral Returns an ICoreWebView2Deferral object.
put_Handled Sets whether the ContextMenuRequested event is handled by host after the event handler completes or if there is a deferral then after the deferral is completed.
put_SelectedCommandId Sets the selected command for the WebView to execute.

Will contain the selection information and a collection of all of the default context menu items that the WebView would show. Allows the app to draw its own context menu or add/remove from the default context menu.

Applies to

Product Introduced
WebView2 Win32 N/A
WebView2 Win32 Prerelease 1.0.1010

Members

get_ContextMenuTarget

Gets the target information associated with the requested context menu.

public HRESULT get_ContextMenuTarget(ICoreWebView2ExperimentalContextMenuTarget ** value)

See ICoreWebView2ContextMenuTarget for more details.

get_Handled

Gets whether the ContextMenuRequested event is handled by host.

public HRESULT get_Handled(BOOL * value)

get_Location

Gets the coordinates where the context menu request occurred in relation to the upper left corner of the WebView bounds.

public HRESULT get_Location(POINT * value)

get_MenuItems

Gets the collection of ContextMenuItem objects.

public HRESULT get_MenuItems(ICoreWebView2ExperimentalContextMenuItemCollection ** value)

See ICoreWebView2ContextMenuItemCollection for more details.

get_SelectedCommandId

Gets the selected CommandId.

public HRESULT get_SelectedCommandId(INT32 * value)

GetDeferral

Returns an ICoreWebView2Deferral object.

public HRESULT GetDeferral(ICoreWebView2Deferral ** deferral)

Use this operation to complete the event when the custom context menu is closed.

put_Handled

Sets whether the ContextMenuRequested event is handled by host after the event handler completes or if there is a deferral then after the deferral is completed.

public HRESULT put_Handled(BOOL value)

If Handled is set to TRUE then WebView will not display a context menu and will instead use the SelectedCommandId property to indicate which, if any, context menu item to invoke. If after the event handler or deferral completes Handled is set to FALSE then WebView will display a context menu based on the contents of the MenuItems property. The default value is FALSE.

put_SelectedCommandId

Sets the selected command for the WebView to execute.

public HRESULT put_SelectedCommandId(INT32 value)

The value is obtained via the ContextMenuItem CommandId property. This value should always be from context menu items for the relevant context menu and event arg. Attempting to mix will result in invalid outputs. The default value is -1 which means that no selected occurred.