Checking if NSButton is down on drawRect Checking if NSButton is down on drawRect xcode xcode

Checking if NSButton is down on drawRect


I solved this by checking [self isHighlighted].


I don't think "drawRect:" is the right place to try to catch this.

You can subclass NSButton and then override either mouseDown: or setState: (looking for "NSOnState", which signifies the button is either selected or being pressed on).


I ended up checking the mouseDownFlags on the buttons cell. Don't know if it's the "right" way to do it, so let me know if you have a better suggestion. Solution is updated in the question above.