ControllerMate (part 4 of 14): One Button, Two Actions (Short Click versus Long Click)
Note: this is not a substitute for the original and most excellent ControllerMate tutorial. I am endeavoring to save some time for those who have read it and now are eager to get things done.
Important: I strongly recommend that for the duration of this adventure you find and connect an extra mouse to your Mac – that way even if you mis-configure your target device you will still have full control.
I have already discussed how you can attach two actions to one button and initiate them with a single click or a double click.
Well, sometimes it is preferable to use a “short click versus long click” combination instead.
For example, I have a controller (a kind of a castrated keyboard) where the buttons tend to stick a bit. So double-clicking becomes a bit of a hassle. Long-clicking (“press and hold”) does the job just fine though.
Here is how you implement this in ControllerMate:
The main active component here is the Delay block (set here for 1 second, but you can change that in the block’s inspector). Output of the delay goes to the ON/OFF latch, so that your keypress registers in the left (Long Click) branch ONLY if you hold it over a second.
The rest of the logic (AND and NOT blocks) make sure that if you do perform a long click, it does not trigger the short click action.
The useful feature of this particular design is that the long click registers as soon as the required time expires but before you release the button. You do not have towonder if you have held it long enough before releasing. You just press and hold till you see the required action!
Next we shall see what can be done with two buttons pressed at the same time.