• 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: Fredrik Olsson <email@hidden>
  • Date: Wed, 02 Aug 2006 10:34:03 +0200

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.


This one is a hard nut to crack. Basically I downloaded the source to Camino and checked out how they do it.
And these are my findings:


First of all you need a subclass of NSButtonCell, I chose to call mine MTDelayedButtonCell.
You need to override the method trackMouse:inRect:ofView:untilMouseUp: to be able to check if you have a "simple click" or a press and hold time out that should bring up a popup menu, or whatever. I choose to trigger a secondary action, I think it is more general and better for reuse.
Also override the class method prefersTrackingUntilMouseUp to return YES.


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.


// Fredrik Olsson

_______________________________________________
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


  • Follow-Ups:
    • Re: NSToolbarItem with pull down menu
      • From: Annard Brouwer <email@hidden>
References: 
 >NSToolbarItem with pull down menu (From: Zef RosnBrick <email@hidden>)

  • Prev by Date: RE: RedMon
  • Next by Date: RE: NSToolbarItem with pull down menu
  • Previous by thread: Re: NSToolbarItem with pull down menu
  • Next by thread: Re: NSToolbarItem with pull down menu
  • Index(es):
    • Date
    • Thread