Re: Playing around with BWToolKit
Re: Playing around with BWToolKit
- Subject: Re: Playing around with BWToolKit
- From: Brandon Walkin <email@hidden>
- Date: Sun, 16 Nov 2008 06:24:33 -0500
On 16-Nov-08, at 5:10 AM, Nathan Kinsinger wrote:
On Nov 16, 2008, at 1:50 AM, Brandon Walkin wrote:
Hi Dave,
If the user isn't able to configure the toolbar, then all you need
to do is get a reference to the BWSelectableToolbar and call this
method on it:
- (void)switchToItemAtIndex:(int)anIndex animate:(BOOL)shouldAnimate
The index is the raw toolbar index - it's zero based and includes
spaces and separators. And in your case you'd pass in NO for
animation. In a future version of BWToolkit, I'll likely make this
more obvious and base it on the item identifier or the item label
rather than the index.
Cheers,
Brandon
On 15-Nov-08, at 8:51 PM, Dave DeLong wrote:
Hey everyone,
I've been playing around with Brandon's new BWToolKit, and I was
wondering if there's any way to hook the ToolbarItems up through
code. I've got a window with four different sections, and I want
to have some NSMenuItems that, when selected, will open the window
to the appropriate section.
The closest I've come is to grab all the item identifiers and
select them that way, but I was wondering if anyone's found a more
robust way to do that.
Thanks,
Dave
I've been playing with this too, and I used -setSelectedIndex:
because that is in your header and -switchToItemAtIndex:animate: is
marked as private. I also tried using NSToolbar's -
setSelectedItemIdentifier:, however that causes the toolbar icon to
change but not the view, so you may want to override that.
1) add:
- (void)setSelectedItemIdentifier:(NSString *)itemIdentifier
{
selectedIndex = [itemIdentifiers indexOfObject:itemIdentifier];
[self switchToItemAtIndex:[self
toolbarIndexFromSelectableIndex:selectedIndex] animate:YES];
}
2) change line 284 in -selectItemAtIndex: to call supers
implementation:
[super setSelectedItemIdentifier:identifier];
Using the label to change the toolbar selection is not a good idea
because the labels may be localized and then they won't match. And
using the index only works for toolbars that can't be modified. You
could create a custom NSToolbarItem class in IB and add the
identifier to the IB inspector, that way developers can set custom
identifiers in IB like they can when creating the toolbar items in
code.
One more thing, any of the headers (like BWSelectableToolbar.h) that
users of your framework may need to use your classes, should be
marked as public so that the headers are exported with the framework
and then we can include them like:
#import "BWToolkitFramework/BWSelectableToolbar.h"
--Nathan
Thanks for the suggestions. I'll implement them for the next release.
Just a note: I'm tracking issues on Bitbucket so if you have any other
bugs or feature enhancements, please post them there. http://www.bitbucket.org/bwalkin/bwtoolkit/issues/
Cheers,
Brandon
_______________________________________________
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