• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Binding Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding Question


  • Subject: Binding Question
  • From: Jonathan Wight <email@hidden>
  • Date: Thu, 6 May 2004 12:04:10 -0400

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.


  • Follow-Ups:
    • Re: Binding Question
      • From: Jonathan Wight <email@hidden>
  • Prev by Date: Re: Saving Web Content
  • Next by Date: Loosely in the Window Menu with Diamonds
  • Previous by thread: Re: SharedChaches folder
  • Next by thread: Re: Binding Question
  • Index(es):
    • Date
    • Thread