Re: NSToolbarItem with pull down menu
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