Skip to content

Latest commit

 

History

History
44 lines (27 loc) · 3.26 KB

popupmenu_showasync_583519687.md

File metadata and controls

44 lines (27 loc) · 3.26 KB
-api-id -api-type
M:Windows.UI.Popups.PopupMenu.ShowAsync(Windows.Foundation.Point)
winrt method

Windows.UI.Popups.PopupMenu.ShowAsync

-description

Shows the context menu at the specified client coordinates.

-parameters

-param invocationPoint

The coordinates (in DIPs), relative to the window, of the user's finger or mouse pointer when the oncontextmenu event fired. The menu is placed above and centered on this point.

Note

For VB, C#, and C++, this window is the CoreWindow associated with the thread that is calling the context menu.

-returns

A IUICommand object that represents the context menu command that was invoked by the user, after the ShowAsync call completes.

If no command is invoked, ShowAsync returns null.

-remarks

You can see complete code examples that demonstrate how to create and customize context menus in the Context menu sample.

-examples

Before you can show a context menu, you must add an event listener for the oncontextmenu event. For example, the Context menu sample listens for the event on specific HTML elements, and then calls the scenario1AttachmentHandler function.

[!code-jsaddcontextmenueventlistener_js]

[!code-jsaddandshowwithhandlers_js]

Additionally, make sure you check that a command was invoked and process that case as appropriate for your app. If the UICommand that is invoked has a callback function (onSaveAttachment in the example), the callback function will be executed. Otherwise, you may need to use UICommand.Id to identify and process the invoked command.

-see-also

Adding context menus, Context menu sample, Guidelines and checklist for , IUICommand, oncontextmenu, Point, PopupMenu.Commands, UICommand