• 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
Re: NSToolbarItem with pull down menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSToolbarItem with pull down menu


  • Subject: Re: NSToolbarItem with pull down menu
  • From: Annard Brouwer <email@hidden>
  • Date: Wed, 2 Aug 2006 12:02:14 +0200

On 2 Aug 2006, at 10:34, Fredrik Olsson wrote:
Zef RosnBrick skrev:
Can anybody give me a clue as to where to find information on how to create a toolbar item with a pulldown menu (like those in Xcode, Pages, etc.)?
I've googled everything I can think of, and can't find a thing.


First of all you need a subclass of NSButtonCell, I chose to call mine MTDelayedButtonCell.
<snip>
Secondly programmatically create a NSButton and replace it's cell with an instance of your subclass, and add it to the toolbar.


I can send you the code for my subclass if you like.

If we're talking about a popup menu: do you have an issue where the user selected to have a text toolbar and the selected menu item doesn't refresh until you toggle the toolbar visibility?
If you don't have this issue, I'd like to have a look at your class as well please! :-)


Here's what I'm doing now for a popup menu, it works great except for the glitch above that I can't seem to fix this way:

- (NSToolbarItem *)createPopUpToolbarItem
{
    NSToolbarItem *toolbarItem;
    NSMenuItem *sourcesMenuItem;

toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: @"PopUpToolbarItemID"] autorelease];

[toolbarItem setLabel: @"PopUpMenu"];
[toolbarItem setPaletteLabel: @"PopupMenuLabel"];
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(selectPopUp:)];
// popUpView is a view in the nib that contains the NSPopUpButton
[toolbarItem setView: popUpView];
[toolbarItem setMinSize: [popUpView bounds].size];
[toolbarItem setMaxSize: [popUpView bounds].size];


    sourcesMenuItem = [[[NSMenuItem alloc] init] autorelease];
    [sourcesMenuItem setSubmenu: [selectPopUp menu]];
    [sourcesMenuItem setTitle: [[selectPopUp selectedItem] title]];
    [toolbarItem setMenuFormRepresentation: sourcesMenuItem];
    if ([toolbarItem respondsToSelector: @selector(setAutovalidates:)])
        [toolbarItem setAutovalidates: YES]; // Tiger only
    return toolbarItem;
}

Cheers!
Annard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSToolbarItem with pull down menu (From: Zef RosnBrick <email@hidden>)
 >Re: NSToolbarItem with pull down menu (From: Fredrik Olsson <email@hidden>)

  • Prev by Date: RE: NSToolbarItem with pull down menu
  • Next by Date: jpg file from virtual printer
  • Previous by thread: Re: NSToolbarItem with pull down menu
  • Next by thread: RE: NSToolbarItem with pull down menu
  • Index(es):
    • Date
    • Thread