• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSSegmentedControl in a toolbar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSSegmentedControl in a toolbar


  • Subject: NSSegmentedControl in a toolbar
  • From: Flavio Donadio <email@hidden>
  • Date: Tue, 4 May 2010 20:54:13 -0300

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSSegmentedControl in a toolbar
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: [[NSFileManager alloc] init] considered thread-safe
  • Next by Date: Re: NSSegmentedControl in a toolbar
  • Previous by thread: Re: [[NSFileManager alloc] init] considered thread-safe
  • Next by thread: Re: NSSegmentedControl in a toolbar
  • Index(es):
    • Date
    • Thread