Re: Binding button.enabled to "NSTextField is not empty"
Re: Binding button.enabled to "NSTextField is not empty"
- Subject: Re: Binding button.enabled to "NSTextField is not empty"
- From: Andrew White <email@hidden>
- Date: Wed, 27 Apr 2005 10:01:34 +1000
Ken, Alex, thanks for the responses.
My understanding of the basic model (based on Ken's code):
I have an NSObjectController. This models my "system". I add a "myText"
(or "myString" in Alex' code) property to this controller to hold the text
that both the field and the button will operate upon.
I associate the value of the text field with the value of
'selection.myText'. Changes to one will be reflected in the other.
I associate the 'enabled' state of the button with the value of
"selection.myText" transformed through a NSIsNotNil boolean test. When
selection.myText changes, the value of this transformation will also change.
Now the inevitable questions:
(1) Why do you bind to 'selection' rather than some other key?
(2) What do the 'editable' and 'automatically prepares content' buttons in
the NSObjectController do?
I assume 'editable' means that bound classes can change the contents. If
it's not 'editable', who (if anyone) can change the contents, and how do
they notify bindings that they've done so?
(3) I notice the value transformer is set to 'raise for non-applicable
keys'. I assume this means it invokes exception handling if I can't apply
NSIsNotNil to the value type? If this is not set, what happens?
(4) If I bound to a check box (via the transformer) rather than a button,
what would happen if the user tried to un-check the check box?
To Alex specifically:
(5) Why use a controller object and a NSArrayController rather than an
NSObjectController?
General again:
(6) If I want to snarf the value of the text field (as part of the action
invoked when the button is pressed), do I connect my outlet to the text
field or to the NSObjectController? What is the functional difference? Is
one or other preferred?
--
Andrew White
--------------------------------------------------------------------------
This email and any attachments may be confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
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