Re: how to validate toolbar with different target?
Re: how to validate toolbar with different target?
- Subject: Re: how to validate toolbar with different target?
- From: Marc Respass <email@hidden>
- Date: Sat, 11 Nov 2006 15:11:45 -0800
I tried binding the toolbaritem when I create it. The toolbarItem's target is the array controller and I bind "enabled"
[toolbarItem bind:@"enabled" toObject:[toolbarItem target] withKeyPath:@"canAdd" options:nil];
I also threw in
BOOL does = [toolbarItem respondsToSelector:@selector(bind:toObject:withKeyPath:options:)];
and does == YES
but it doesn't work. I have a standard button bound the same way and it does the right thing. It seems like something is going on with bindings that NSToolbarItem is not in on. Oh, NSKeyValueBindingCreation is a category on NSObject so it makes sense that it responds if it doesn't do anything.
Thanks. At least I know where to look now.
Marc
On Saturday, November 11, 2006, at 04:47PM, "Andrew Merenbach" <email@hidden> wrote:
>Hi, Marc.
>
>Toolbar validation is indeed sent to the target, so you would need to
>make a subclass for your NSArrayController. But, if you can, I.
>Savant's suggestion (re: bindings) may work far better.
>
>Cheers,
> Andrew
>
>On 11 Nov 2006, at 13:12, Marc Respass wrote:
>
>> Hi,
>>
>> I have some buttons in my window's toolbar that are bound to an
>> NSArrayController (selectNext, selectPrevious, add, remove, etc).
>> This is a non-document based CoreData app. My AppDelegate is also
>> the window (with the toolbar) delegate and I implement
>>
>> -(BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem
>>
>> which works fine for the Save button because the Save button's
>> target is the app delegate but it doesn't get called for any of the
>> buttons whose target is the array controller. This leads me to
>> think that toolbar validation is sent to the target of the
>> toolbaritem. Is that correct? If so, I expect that I will need to
>> subclass NSArrayController and put the validation there. What would
>> be cool is subclassing NSArrayController, adding a delegate, and
>> somehow forwarding the message. Or maybe I can just forward some
>> messages to the NSArrayController. This is not something I've ever
>> done but I remember hearing people talk about message forwarding in
>> Cocoa and WebObjects.
>>
>> Any tips are appreciated.
>>
>> Thanks
>> Marc
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> 40ucla.edu
>>
>> This email sent to email@hidden
>
>
>
_______________________________________________
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