ControllerMate ( part 3 of 14 ): One Button, Two Actions (Single Click versus Double 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.

This is part Three in a series of posts. For the full table of contents go here or here.


Mac OS X promotes consistent use of “Back” and “Forward” buttons. If you have dedicated Back and forward buttons on your fancy-shmancy keyboard, they will work right away.

I have been using the middle button of my mouse as the “back” button for ages, but, having gotten to know ControllerMate, decided to turn it into a combined Back/Forward control.

The goal:  Single-click = Back; Double-click = Forward.

The solution is simple:Back-Forward

By the way, it is a bit easier to debug these things if you use sounds instead of keystroke as the outcome (at least till you get it right) like this:

OneButtonTwoActions

So, what happens here?

The only input is the middle button (Button #3).

If I click twice within 0.30 seconds, the Pulse Count block flips its output to ON and causes the keystroke block to enter the hotkey combination for the “Forward” action.  (Yes, you can change the time window and the hotkey – just look at the Inspector for the respective blocks – it is really straightforward.)

As soon as i make the very first click, the Delay block starts counting 0.30 seconds. During that time it does not pass on the click. This gives us the 0.30 seconds to finish the double-click.

If we never turn our single click into a double-click, then in 0.30 seconds the Delay block changes its output to ON and passes it through the Gate block on to the Keystroke. The keystroke for “Go Back” is generated.

If the single click becomes a double-click, we do not want the output of Delay block to ever generate the “Back” keystroke. That is why successful Pulse Count also causes Dwell block to switch off the ON/OFF gate, so that the signal from Delay Block never gets anywhere.

Mission accomplished: Single Click = Back, Double-Click = Forward.

You can, of course, use the same method with a different mouse button. Or a keyboard button. Or with your joystick. And you can assign different keystrokes.

Bottom line: One Button, Two Actions.

P.S. In some designs it may become important to register the single click at the point of release, not at the moment you press. This way you can use the mouse button to drag-select multiple objects and then on release execute an action. The solution is coming in my later post.

P.P.S:  “Single- versus double- click” is a familiar concept, but sometimes it is preferable to use a “short click versus long click” combination instead.

Advertisements

About this entry