CoreWebView2ContextMenuTarget Class

Represents the information regarding the context menu target. Includes the context selected and the appropriate data used for the actions of a context menu.

Summary

Members Description
FrameUri Gets the uri of the frame. Will match the CoreWebView2ContextMenuTarget.PageUri if CoreWebView2ContextMenuTarget.IsRequestedForMainFrame is true.
HasLinkText Returns true if the context menu is requested on text element that contains an anchor tag.
HasLinkUri Returns true if the context menu is requested on HTML containing an anchor tag.
HasSelection Returns true if the context menu is requested on a selection.
HasSourceUri Returns true if the context menu is requested on HTML containing a source uri.
HasSpellingError Returns true if the context menu target contains a spelling error.
IsEditable Returns true if the context menu is requested on an editable component.
IsRequestedForMainFrame Returns true if the context menu was requested on the main frame and false if invoked on another frame.
Kind Gets the kind of context that the user selected as CoreWebView2ContextMenuTargetKind.
LinkText Gets the text of the link (if CoreWebView2ContextMenuTarget.HasLinkText is true, null otherwise).
LinkUri Gets the uri of the link (if CoreWebView2ContextMenuTarget.HasLinkUri is true, null otherwise).
PageUri Gets the uri of the page.
SelectionText Gets the selected text (if CoreWebView2ContextMenuTarget.HasSelection is true, null otherwise).
SourceUri Gets the active source uri of element (if CoreWebView2ContextMenuTarget.HasSourceUri is true, null otherwise).
GetSpellCheckSuggestionsAsync Asynchronously retrieves spelling corrections for the misspelled word associated with the context menu target as a read-only collection of CoreWebView2SpellCheckSuggestion objects.

Properties

FrameUri

readonly string FrameUri

Gets the uri of the frame. Will match the CoreWebView2ContextMenuTarget.PageUri if CoreWebView2ContextMenuTarget.IsRequestedForMainFrame is true.

HasLinkText

readonly bool HasLinkText

Returns true if the context menu is requested on text element that contains an anchor tag.

HasLinkUri

readonly bool HasLinkUri

Returns true if the context menu is requested on HTML containing an anchor tag.

HasSelection

readonly bool HasSelection

Returns true if the context menu is requested on a selection.

HasSourceUri

readonly bool HasSourceUri

Returns true if the context menu is requested on HTML containing a source uri.

HasSpellingError

readonly bool HasSpellingError

Returns true if the context menu target contains a spelling error. When true, call CoreWebView2ContextMenuTarget.GetSpellCheckSuggestionsAsync to retrieve the available spelling corrections asynchronously.

IsEditable

readonly bool IsEditable

Returns true if the context menu is requested on an editable component.

IsRequestedForMainFrame

readonly bool IsRequestedForMainFrame

Returns true if the context menu was requested on the main frame and false if invoked on another frame.

Kind

readonly CoreWebView2ContextMenuTargetKind Kind

Gets the kind of context that the user selected as CoreWebView2ContextMenuTargetKind.

LinkText

readonly string LinkText

Gets the text of the link (if CoreWebView2ContextMenuTarget.HasLinkText is true, null otherwise).

LinkUri

readonly string LinkUri

Gets the uri of the link (if CoreWebView2ContextMenuTarget.HasLinkUri is true, null otherwise).

PageUri

readonly string PageUri

Gets the uri of the page.

SelectionText

readonly string SelectionText

Gets the selected text (if CoreWebView2ContextMenuTarget.HasSelection is true, null otherwise).

SourceUri

readonly string SourceUri

Gets the active source uri of element (if CoreWebView2ContextMenuTarget.HasSourceUri is true, null otherwise).

Methods

GetSpellCheckSuggestionsAsync

IAsyncOperation<IVectorView<CoreWebView2SpellCheckSuggestion>> GetSpellCheckSuggestionsAsync()

Asynchronously retrieves spelling corrections for the misspelled word associated with the context menu target as a read-only collection of CoreWebView2SpellCheckSuggestion objects. Each suggestion's CoreWebView2SpellCheckSuggestion.SuggestionText is the correction text. Its CoreWebView2SpellCheckSuggestion.CommandId can be passed to CoreWebView2ContextMenuRequestedEventArgs.SelectedCommandId to apply the correction, using the same commanding path as built-in context menu items.

Before awaiting this method, set CoreWebView2ContextMenuRequestedEventArgs.Handled to true and obtain a deferral by calling CoreWebView2ContextMenuRequestedEventArgs.GetDeferral. Hold the deferral until the custom menu closes. If a suggestion is selected, assign its command ID to CoreWebView2ContextMenuRequestedEventArgs.SelectedCommandId before completing the deferral. Complete the deferral even if no suggestion is selected.

The returned operation may already be complete if suggestions are ready. Otherwise, it completes when they become available. Multiple concurrent calls are supported. Each operation receives a collection containing the same suggestions in the same order when its call completes. Collection and suggestion object identity across calls is unspecified. The result is an empty collection if no suggestions are available or if CoreWebView2ContextMenuTarget.HasSpellingError is false.

Referenced by