Re: Binding Question
Re: Binding Question
- Subject: Re: Binding Question
- From: Jonathan Wight <email@hidden>
- Date: Thu, 6 May 2004 15:14:38 -0400
Well I worked out the answer to my question. Turns out I'm having one
of those "can't see glaringly obvious answer in the documentation"
days.
Adding a binding to a view object turns out to be surprisingly more
complex than I expected. I was expecting to just expose the binding and
add some methods to the setter methods. Fortunately the "How Do
Bindings Work?" doc put me straight.
Jon.
P.S. Very nice work on the new NSController docs Apple. I'll try and
read them more thoroughly before asking any more dumb questions ;-)
On May 06, 2004, at 12:04, Jonathan Wight wrote:
>
I have a NSPopupButton subclass that is used for the selection of
>
AppleScripts. The menu items in the menu are populated from the
>
application's built-in scripts (in the app's shared support directory).
>
At the bottom of the menu is a "Other" button allowing the user to
>
select a custom script. To accomplish this the popup sets its target to
>
itself and sets the action of the "Other" menu item to a selector
>
defined in the button's class. When the script is changed the button's
>
"scriptUrl" attribute is set (via a setScriptUrl method). (You can see
>
how the popup button works if you download iRoster from
>
http://toxicsoftware.com/ and look at the Actions dialog in the browser
>
preferences).
>
>
So I'm adding binding support to this class and have added the required
>
[self exposeBinding:@"scriptUrl"] call into the +initialize method.
>
I've also added the class to an Interface Builder palette so I can set
>
the binding in Interface Building.
>
>
Because the scriptUrl attribute takes an NSURL and the controller will
>
contains string I've created an NSURL <-> NSString NSValueTransformer
>
object.
>
>
I've added the popup button to my NIB and bound it to my controller
>
(actually a subkey of the selection of a NSArrayController). I've set
>
the bindings transform to the NSValueTransformer I mentioned
>
previously. For debugging purposes I also have a NSTextField bound to
>
the same key the popup button is bound to...
>
>
Now when I run the application and change the text in the debugging
>
text field the changes are reflected in the popup menu. This is very
>
good!
>
>
Unfortunately when I choose a script via the popup the value of
>
debugging text field are not updated. Basically the NSController isn't
>
realising that the popup button's scriptUrl attribute has changed. What
>
binding magic do I have to perform to accomplish this?
>
>
I've tried using willChangeValueForKey, objectDidBeginEditing and
>
commitEditing to no success. What am I missing?
>
>
Jon.
>
>
[demime 0.98b removed an attachment of type
>
application/pkcs7-signature which had a name of smime.p7s]
>
_______________________________________________
>
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.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.