How to detect a click
If you’ve ever written something that needs to simulate menu behavior, you’ve probably noticed that it would be nice to know, portably to future OS versions, how long you should wait before rejecting a mouse-down/mouse-up pair as not a click, as well as how far the user must move the mouse for it to not be a click.
The way to do this is:
EventTime clickTimeout;
HISize clickMaxDistance;
OSStatus err = HIMouseTrackingGetParameters(kMouseParamsSticky, &clickTimeout, &clickMaxDistance);
There is no Cocoa API for this.
January 7th, 2007 at 05:58:15
I think the duration thing should be handled globally, not on a per-application basis. That’s the point of the mouse panel in system preferences, right? Or am I misunderstanding you. I use NSEvent’s -clickCount.
January 7th, 2007 at 06:24:14
I’m sure it propagates to all applications, just like the HI scale factor and the double-click time.
-clickCount
tells you whether you have a single-, double-, triple-, or quadruple-click on your hands. Sticky testing means comparing a mouse-up event to the mouse-down before it.You must open the menu when
January 7th, 2007 at 20:06:24
Wow, this is pretty obscure — nobody brought it up when I filed rdar://4556731, complaining about the lack for Cocoa. This looks like a perfectly good API. (I’ll have to see if it gives the same values I ended up using…)