To get rid of the previous one, if you want to create a custom button, the way in which it can distinguish clicking on releases from releases, try adding the isPressed property to it and the following code:
(void)mouseDown:(NSEvent *)event { self.isPressed = true; [super mouseDown:event]; self.isPressed = false; [self.target performSelector:self.action withObject:self]; }
A custom button must be configured to send actions to:
[self.button sendActionOn: NSLeftMouseDownMask | NSLeftMouseUpMask];
Without this, the action method is not called until the button is released.
In the action method, you can request isPressed . eg:
int state = (int)[sender isPressed];
The unfortunate but harmless βfeatureβ of this is that the action method is called twice when the button is released: once from within the NSButton with isPressed is still true. (This should be ignored.) The second time from the user button is the performSelector method, with isPressed false.
Any comments if this might work in future versions?
Allen king
source share