A regular NSButton seems to be transparent if it’s disabled.
Image shows a Button with style 'push'
However, I want to disable the Button without the transparency.
I’ve tried to programmatically set the alphaValue to 1.0 but it seems that the NSButtons cell (controlView) as well as all other subviews are already at an alphaValue of 1.0.
Also, there’s nothing like userInteractionEnabled or adjustsImageWhenDisabled (both recommended here) I could use like in iOS.
How can I disable a NSButton without the standard transparency?
EDIT: Also a 'textured push' button appears to be transparent:


If you don't need the title, and will provide your own button image, you can use
setImageDimsWhenDisabledto disable transparency inNSButtonCell's image when it is disabled. Here is the code:NSButtonCellis the subview ofNSButton. But as I said, the title will still be "dimmed" a little bit, and also its background. But since image if on top of the background, you won't see the transparent background.Another way (avoid subclass NSButton) is to have your own state tracking variable for button. When the state is disabled, dismiss any click event. Sample framework of code is like this:
This may show the highlight when clicked. You can disable highlight also. But this is not a good idea if you have many buttons. If you have many buttons, subclass NSButton is the best choice.