Menu

Triple-Clicks revisited: implementing N-Clicks

November 28, 2009 - Programming

In my previous entry, I discussed and provided code that would allow for the detection of Triple-Clicks on a window. By extending the provided architecture, it is relatively trivial to allow any number of consecutive clicks; for example, detecting pentuple clicks.

The revisions are pretty easy; in my case, I created a structure to hold what I previous had in a few module-level variables, to keep track of various data about each consecutive “click set” if that is a proper word to use here. Things such as the first click position, the last click position (these will obviously be the same for the “first” consecutive click (which is just a single-click, really) but could be used in later clicks to compare the distance values used, retrieved via GetSystemMetrics() using the SM_DRAGX and SM_DRAGY constants,(or was it SM_XDRAG and SM_YDRAG…) and comparing these values with the difference between each successive click. The ideal solution would be to compare each click position with the first click position, so that the clicking cannot move across the object very far from where the first click took place. The logic is pretty simple, and should be easy to follow. The project can be downloaded from here.This is a tad different then the previous one, and is instead implemented as a sort of  “game”.

There are a few design and User interface considerations when using Multiple clicks in your UI; the most prevalent is probably that unless you tell your users that they can triple-click or quadruple click, they likely will not try it- that is, it isn’t really that intuitive. Additionally, when you do implement this behaviour, remember that, for example, with a triple click, a double click was already fired and handled before that; so don’t make successive clicks do vastly different things. the ideal scenario is to use successive clicks to do the same thing, but change the scope; for example, Word allowed you to click,double-click, and triple click text. the first click sets the position of the cursor, the second click selects the word that the cursor is in, and a triple click selects a paragraph. (In the outlook editor it actually selects the sentence I think, but let’s not split hairs…). In fact, it would make sense to conclude that as an unsaid rule you should only use triple clicks to build on behaviour that the single and double-clicks before them have already done, just as word does. if you make triple-clicks do something esoteric, such as, for example, triple clicking a drawing to save, consider instead opting for a toolbar button or menu item to perform this task, or perhaps a key combination (or both).

Have something to say about this post? Comment!