Ash Furrow
Ash Furrow

Reputation: 12421

NSButton draw alternate image on click

I know this is probably super easy, but I'm having a hard time wading through header files and could use some guidance.

I have an NSPopUpButton defined in a nib with a menu attached to it. I have defined it in the nib to be "Pull Down" type with no arrow (the images given to me by our designer include a special arrow he wants to use). It is a borderless button. The title properly is empty, though I have set the image and alternateImage.

What I'm looking for is a configuration, either in the nib, file's owner implementation, or by subclass NSPopUpButton, that will allow me to display the button's alternate image (or any other image) while the button's menu is being displayed. Instead, it looks like the system is dimming the button's image.

I've tried numerous nib configurations, various properties of NSButton and NSButtonCell, overriding mouseDown and mouseUp. Nothing I do works.

Upvotes: 1

Views: 2287

Answers (2)

Jim Dovey
Jim Dovey

Reputation: 11156

I think it's custom NSButtonCell class time; I don't know of any way to override the theme for this type of button.

Your only alternative would be to use a regular NSButton with the appropriate image and show the menu at the correct position manually, which would probably be a lot easier to implement.

Upvotes: 2

iKenndac
iKenndac

Reputation: 18776

If playing with the "Type" property doesn't help, you may well have to subclass the drawing of NSButtonCell to get what you want.

- (void)drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView *)controlView in NSButtonCell seems promising.

Upvotes: 4

Related Questions