I was working on a similar issue on C++
Firstly, you need to understand how the events are fired, i 'll take click using the left mouse button:
- Click once -> Left button click event fired
- Double click -> Left double click event fired
Windows only support you up to this level.
For triple click, it's essentially a click following a double click with the in-between time small enough. So, what you need to do is handle a click event, check if there was a double click before that and fire a triple click event.
Though the code is different, this is how I do it:
- Declare doubleClickTime & doubleClickInterval to store the last time we double click & the time between clicks.
- Declare tripleClickEventFired to indicate we have already fired an event (init to false)
Handlers
Click Handler
if ((clock() - doubleClickFiredTime) < doubleClickInterval)
<fire triple click event>
tripleClickFired = true;
else
<fire click event>
Double click handler
doubleClickTime == clock()
doubleClickInterval == GetDoubleClickTime() * CLOCKS_PER_SEC / 1000;
If ( !tripleClickEventFired)
<fire doubleClickEvent>
else
tripleClickEventFired = false;
The functions I use was:
- clock(): get the current system time in UNIT
- GetDoubleClickTime(): a function provided by Windows to get the time between clicks
- the "* CLOCKS_PER_SEC / 1000;" part is meant to covert the return value of GetDoubleClickTime() to UNIT'''
NOTE: the 3rd click fires both a Click and Double Click event on system level