I have created an NSButton that uses an image only and no text. I create the button using the following code. The code is called from the containing window's awakeFromNib
.
[[self contentView] addSubview:closeButton];
[[closeButton cell] setImageDimsWhenDisabled:YES];
[closeButton setBezelStyle:NSRoundedBezelStyle];
[closeButton setButtonType:NSMomentaryChangeButton];
[closeButton setBordered:NO];
[closeButton setImage:[NSImage imageNamed:@"title-close"]];
[closeButton setAlternateImage:[NSImage imageNamed:@"title-close-alt"]];
[closeButton setTitle:@""];
[closeButton setImagePosition:NSImageOnly];
[closeButton setFocusRingType:NSFocusRingTypeNone];
[closeButton setTarget:self];
[closeButton setAction:@selector(performClose:)];
[closeButton setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin];
if(!_hasCloseWindowButton)
[closeButton setEnabled:NO];
If I don't make the call to [closeButton setEnabled:NO]
the button is drawn and works perfectly.
If [closeButton setEnabled:NO]
is called, the button is either hidden or not being drawn.
Is there some way to specify an image for the disabled state that I am somehow missing in the docs ?
Does anyone have a clue what I might be doing wrong?