다음을 통해 공유


PopupMenu.ShowAsync(Point) 메서드

정의

지정된 클라이언트 좌표의 상황에 맞는 메뉴를 표시합니다.

public:
 virtual IAsyncOperation<IUICommand ^> ^ ShowAsync(Point invocationPoint) = ShowAsync;
IAsyncOperation<IUICommand> ShowAsync(Point const& invocationPoint);
public IAsyncOperation<IUICommand> ShowAsync(Point invocationPoint);
function showAsync(invocationPoint)
Public Function ShowAsync (invocationPoint As Point) As IAsyncOperation(Of IUICommand)

매개 변수

invocationPoint
Point

oncontextmenu 이벤트가 발생했을 때 사용자의 손가락 또는 마우스 포인터의 창을 기준으로 하는 좌표(DIP)입니다. 메뉴는 위에 배치되고 이 지점의 가운데에 배치됩니다.

참고

VB, C#및 C++의 경우 이 창은 상황에 맞는 메뉴를 호출하는 스레드와 연결된 CoreWindow 입니다.

반환

ShowAsync 호출이 완료된 후 사용자가 호출한 상황에 맞는 메뉴 명령을 나타내는 IUICommand 개체입니다.

명령이 호출되지 않으면 ShowAsync는 null을 반환합니다.

예제

상황에 맞는 메뉴를 표시하려면 먼저 oncontextmenu 이벤트에 대한 이벤트 수신기를 추가해야 합니다. 예를 들어 상황에 맞는 메뉴 샘플 은 특정 HTML 요소에서 이벤트를 수신 대기한 다음 함수를 호출합니다 scenario1AttachmentHandler .

document.getElementById("attachment").addEventListener("contextmenu", attachmentHandler, false);
menu.commands.append(new Windows.UI.Popups.UICommand("Save attachment", onSaveAttachment));

// We don't want to obscure content, so pass in the position representing the selection area.
// We registered command callbacks; no need to handle the menu completion event
menu.showAsync(pageToWinRT(e.pageX, e.pageY)).then(function (invokedCommand) {
    if (invokedCommand === null) {
        // The command is null if no command was invoked.
        WinJS.log && WinJS.log("Context menu dismissed", "sample", "status");
    }
});

또한 명령이 호출되었는지 검사 앱에 적절하게 처리해야 합니다. 호출된 UICommand 에 콜백 함수(onSaveAttachment 예의 경우)가 있는 경우 콜백 함수가 실행됩니다. 그렇지 않으면 UICommand.Id 사용하여 호출된 명령을 식별하고 처리해야 할 수 있습니다.

설명

상황에 맞는 메뉴 샘플에서 상황에 맞는 메뉴를 만들고 사용자 지정하는 방법을 보여 주는 전체 코드 예제를 볼 수 있습니다.

적용 대상

추가 정보