CoreWebView2ContextMenuRequestedEventArgs Class
Event args for the CoreWebView2.ContextMenuRequested event. 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.
Summary
Members | Description |
---|---|
ContextMenuTarget | Gets the target information associated with the requested context menu. |
Handled | Gets or sets whether the CoreWebView2.ContextMenuRequested event is handled by host after the event handler completes or after the deferral is completed if there is a taken Deferral. If Handled is set to true then WebView2 will not display a context menu and will instead use the CoreWebView2ContextMenuRequestedEventArgs.SelectedCommandId property to indicate which, if any, context menu item to invoke. |
Location | Gets the coordinates where the context menu request occurred in relation to the upper left corner of the WebView bounds. |
MenuItems | Gets the collection of CoreWebView2ContextMenuItem objects. |
SelectedCommandId | Gets or sets the selected command for the WebView to execute. The value is obtained via the CoreWebView2ContextMenuItem.CommandId property. |
GetDeferral | Returns a Deferral object. |
Properties
ContextMenuTarget
readonly CoreWebView2ContextMenuTarget ContextMenuTarget
Gets the target information associated with the requested context menu.
Handled
bool Handled
Gets or sets whether the CoreWebView2.ContextMenuRequested event is handled by host after the event handler completes or after the deferral is completed if there is a taken Deferral. If Handled is set to true
then WebView2 will not display a context menu and will instead use the CoreWebView2ContextMenuRequestedEventArgs.SelectedCommandId property to indicate which, if any, context menu item to invoke.
If Handled is set to true
then WebView2 will not display a context menu and will instead use the CoreWebView2ContextMenuRequestedEventArgs.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 CoreWebView2ContextMenuRequestedEventArgs.MenuItems property. The default value is false
.
Location
readonly Point Location
Gets the coordinates where the context menu request occurred in relation to the upper left corner of the WebView bounds.
MenuItems
readonly
IVector
<CoreWebView2ContextMenuItem> MenuItems
Gets the collection of CoreWebView2ContextMenuItem objects.
SelectedCommandId
int SelectedCommandId
Gets or sets the selected command for the WebView to execute. The value is obtained via the CoreWebView2ContextMenuItem.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.
Methods
GetDeferral
Deferral GetDeferral()
Returns a Deferral object. Use this operation to complete the event when the custom context menu is closed.