Fellows,

I tried to search the list for a solution to this problem, but maybe I'm not a 
good searcher.

I am trying to use a NSSegmentedControl in a toolbar, capsule-styled, just like 
in Mail or Preview. I mean: I want each segment to have its own label, like in 
the "Reply / Reply All / Forward" control.

I got this sample code from the dev docs (NSToolbarItemGroup Class Reference):

// Create toolbar items
NSToolbarItem *item1 = [[[NSToolbarItem alloc] initWithItemIdentifier:@"Item1"] 
autorelease];
NSToolbarItem *item2 = [[[NSToolbarItem alloc] initWithItemIdentifier:@"Item2"] 
autorelease];

// Set items' images
[item1 setImage:[NSImage imageNamed:@"LeftArrow"]];
[item2 setImage:[NSImage imageNamed:@"RightArrow"]];

// Set items' labels
[item1 setLabel:@"Prev"];
[item2 setLabel:@"Next"];

// Create an item group and put the previously created items in it
NSToolbarItemGroup *group = [[[NSToolbarItemGroup alloc] 
initWithItemIdentifier:@"GroupItem"] autorelease];
[group setSubitems:[NSArray arrayWithObjects:item1, item2, nil]];

// Set the item group's view to an NSSegmentedControl instance
[group setView:someSegmentedControl];

I put the above code inside the -awakeFromNib method of my AppDelegate and 
then, in the header:

@interface ...
{
...
NSSegmentedControl *someSegmentedControl;
...
}

@property (nonatomic, retain) IBOutlet NSSegmentedControl *someSegmentedControl;
...
@end

Finally, in Interface Builder, I inserted an NSSegmentedControl in my toolbar 
and bound it to the outlet  in the App Delegate instance in the NIB.

It doesn't work. My segmented control doesn't get the images or labels. Should 
it be done this way?


Cheers,
Flavio

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to