Ram
Ram

Reputation: 3153

Win32 : How to trap left and right mouse button clicked at the same time

I am trying to program specific behaviour when the user (clicks and) releases the left and right mouse at the same time. Is there a known way to trap such an event / gesture. I am aware of how to trap leftButtonUp and rightButtonUp but not sure how I can trap this event.

If the left button is pressed and then the right button is pressed with a delta delay, that is OK. When the user releases the right button / left button and if this is followed up by release of other button within a defined epsilon time then such an event should be raised.

Upvotes: 1

Views: 1581

Answers (3)

Hansa Ribe
Hansa Ribe

Reputation: 31

If GetAsyncKey(0x01) && GetAsyncKey(0x02){
DoEvent();
}

Upvotes: 0

Serge
Serge

Reputation: 6095

There is no such event in WinAPI, but you may track it yourself. wParam of all button down/up messages contains information of the state of all buttons at the time of event:

MK_LBUTTON 0x0001 The left mouse button is down.
MK_MBUTTON 0x0010 The middle mouse button is down.
MK_RBUTTON 0x0002 The right mouse button is down.

Thus, you need to keep the track of changes and define a threshold that will filter out all events that you like to consider as a "simultaneous click/release"

Upvotes: 1

CrazyCasta
CrazyCasta

Reputation: 28362

You will need to write your own method of handling this. Record when the first button was clicked, when the other button is clicked see if the first button is still down and if the delay is less than whatever delta you've supplied.

Upvotes: 0

Related Questions