Question

I have this idea of having some kind of "badges" in my app. They should be clickable, have an image and a label. That's the easy part. But I also want them to have this little help button in the upper right corner which is also clickable. The help button should just be an image and should of course also be clickable. What would be the best approach of having this small button inside a larger button? Should I have two buttons above each other?

Was it helpful?

Solution

My suggestion is to bypass trying to beat NSButton into something its not. You can cook up your own "Button" with an NSView or Hierachy of NSViews.

If you are really determined to go the NSButton route perhaps assemble the multiple buttons inside inside an NSView which would be possible inside IB or programatically something like

NSView *container = [[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)];
NSButton *big = [[[NSButton alloc] initWithFrame:NSMakeRect(0,0,100,100)] autorelease];
NSButton *small = [[[NSButton alloc] initWithFrame:NSMakeRect(80,80,20,20)] autorelease];
[container addSubview:big];
[container addSubview:small];
[small setImage:[NSIMage imageNamed:@"query.png"]];
[big setImage:[NSIMage imageNamed:@"cow.png"]];
[big setTitle:@"cow"];

You'd have to beat the buttons into shape a little more but thats the basics.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top