Re: Toolbar item like Finder 'view' item
Re: Toolbar item like Finder 'view' item
- Subject: Re: Toolbar item like Finder 'view' item
- From: Alex Rice <email@hidden>
- Date: Mon, 22 Apr 2002 14:51:11 -0600
On Monday, April 22, 2002, at 02:32 PM, Chris Meyer wrote:
Hi,
What is the best way to put a toolbar item that works like the 'view'
selector in the Finder toolbar into my application? Is it possible to
do it from PB? Is it possible to do it without creating a custom class?
No custom class is needed. First in Interface Builder create an NSView
with whatever content you want for your toolbar item. Then connect this
view to an outlet in your PB class, say the outlet is named:
IBOutlet NSView *myToolbarView;
Then in the NSToolbar delegate method
-toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: the code to
connect it the toolbar item to it's view is something like:
NSToolbarItem *item = [[[NSToolbarItem alloc]
initWithItemIdentifier:itemIdentifier] autorelease];
[item setView: myToolbarView];
[item setMinSize:NSMakeSize(48,32)]; // or whatever
[item setMaxSize:NSMakeSize(48,32)];
[item setLabel:NSLocalizedString(@"Tool Label", nil)];
[item setPaletteLabel:NSLocalizedString(@"Tool Label", nil)];
[item setToolTip:NSLocalizedString(@"Do the thing", nil)];
[item setAction:@selector(myToolbarViewAction:)];
Alex Rice <email@hidden>
Mindlube Software
http://www.mindlube.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.