0
votes

Is there any way to tell whether a pair of mouse up / down events were triggered by a tap on the trackpad, versus a trackpad depression resulting in a click?

Essentially, I'd like to replicate the behavior you see in toggle check boxes throughout macOS. They have four states:

  1. Toggled off: no check
  2. Toggled on: check mark
  3. Activated off: no check / grey background
  4. Activated on: check mark / grey background

If a tap is recognized on a checkbox, it'll go from 1 -> 2 or 2 -> 1 after a brief delay (~0.5s) without showing the grey background at all. However if you physically click the trackpad, you'll go from 1 -> 3 immediately on mouse-down, and then from 3 -> 2 if the mouse-up comes on the checkbox (otherwise it goes back to 1).

It seems that to replicate this behavior one needs to differentiate between a tap-like mouse-down and a click-like mouse down. As far as I can tell there is no way to do this by inspecting NSEvent in NSView.mouseDown.

1

1 Answers

0
votes

Answering this myself: override pressureChange. This method fires on (and during) a physical trackpad click but not a tap-to-click. Anyway this question was also asked here: How to judge NSEvent from trackpad click, not tap to click.