In C++ Windows Store apps, there is an event on the main window called PointerPressed. I'm trying to find how to detect double click as opposed to single click. I don't see an equivalent event to PointerPressed that would trigger upon mouse double click.
I also checked the PointerPressed event arguments and it doesn't seems to contain information about whether or not it is a single or double click.
Its easy to perform it using the DoubleTapped property on the GestureRecognizer, but what if I don't use the gesture recognizer? Is there no way to detect a simple mouse double-click???
Thank you.
Edit: Its a pure C++ Direct3D application targetted for the Windows Store, not using XAML or any user interface thing like that.
There is a DoubleTapped
event on a UIElement
. No need to use a GestureRecognizer
.
Make use of the Pointer.Timestamp property, and check if the time since last mouse press event received is less or equal than you double-click time.
Here is the pseudo-code:
static unsigned long long LastTimestamp = 0;
static unsigned long long DoubleClickTimeMS = 250;
if( event == mouse_down )
{
if( (Pointer->Timestamp - LastTimestamp) / 1000 <= DoubleClickTimeMS )
{
//switch event for a double-click
event = double_click;
}
LastTimestamp = Pointer->Timestamp;
}
This is probably a bad answer as it doesn't answer the question but, conceptually, a click is an event. A doubleclick consists of two clicks which are, respectively, two events. Since a gesture consists of multiple such events, we see that a doubleclick is actually a gesture. Hence, you probably should use the gesture recognizer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With