Search code examples
swiftmacoscocoamouseeventnsbutton

Clicking different NSButtons in quick succession


I have an app where clicking on different buttons in a quick succession is necessary but Cocoa seems to disallow it.

I'm using the same subclass of NSButton on all the button instances and the mouseUp/mouseDown events call actions based on the button's instance tag (defined in IB).

The problem is that clicking different buttons quickly triggers the click on the first button but not the current button being clicked. How do I fix this?

Note: I'm using Swift 3 and targeting the latest macOS.


Solution

  • This turns out to have been a bug with a Wacom tablet driver on macOS Sierra. The driver from a previous OS version was outdated and was registering double clicks in an incorrect way. If anyone encounters this problem, be sure to check your system default for double-click speed.

    This code snippet prints your double-click speed:

    Swift.print(NSEvent.doubleClickInterval())