Reputation: 392
I intend to implement a mouse "dragging" gesture in my application, following the PointerPressed() / PointerMoved() / PointerReleased() pattern. This is a UWP application using the recently released C++/WinRT language projection for Windows.
Thing is, I need to do it using the right mouse button, instead of the left mouse button.
The Pointer****() events currently do not offer a way to know which button was pressed. If you attempt to do a call to GetKeyState() inside the Pointer****() events, the ::RightButton virtual key will always return 0 (None). Also, the RightTapped() event will not fire until the button is released.
Yet, if you attach a PointerPressed() event to a Button (in addition to a Click() event), you will notice that left clicks will fire the Click event, while right clicks will actually fire the PointerPressed() event. So, in theory, it is possible to distinguish between the two mouse buttons (since the API already does it).
Anybody know a way to perform the gesture above in a UWP C++/WinRT application using the right mouse button? Any suggestion will do, I'm currently at my wits end.
Upvotes: 2
Views: 1450
Reputation: 2345
You can check IsRightButtonPressed
value of PointerPointProperties
which can be accessed through PointerRoutedEventArgs
. Say you get PointerRoutedEventArgs e
as parameter in event handler, then
PointerPoint currentPoint = e.GetCurrentPoint(NULL);
PointerPointProperties props = currentPoint.Properties();
if (props.IsRightButtonPressed()) {
// right button pressed!
}
You can check this sample for more details which is in C#. Check GetCurrentPoint
documentation regarding which parameter to pass as argument
Upvotes: 4