This discussion is archived
1750 Views 4 Replies Latest reply: Jan 28, 2009 11:37 AM by YuriNiyazov
Currently Being ModeratedJan 28, 2009 10:56 AM (in response to YuriNiyazov)
The "Add" button is initially disabled. The Add button is enabled/disabled depending on whether the NSTextField is empty or not. This is done by implementing the
- (void)controlTextDidChange:(NSNotification *)aNotification
It might be easier to use key/value binding for this type of problem. It is like Core Data without the database.
(replaced brackets with braces because the posting software turns that into strikethrough)
Use two lines of
with your code in between
to fix that.
however, it is apparent that the delegate methods of the textField are not called when the contents are edited programmatically.
I would have to get knee deep in code to verify that. But if you are doing it programatically, why not just call the delegate yourself?
Anyway - is this the correct and accepted way of doing this in Cocoa, or am I missing something more obvious and more elegant?
I have one program where I have to do things like controlTextDidChange. It is a royal hassle. When I get time I plan to change it all to key/value binding. It is much easier to use.MacBook, Mac OS X (10.5.4), 1.83Ghz/2GB Ram/160 HD
Currently Being ModeratedJan 28, 2009 11:37 AM (in response to etresoft)You are absolutely right as far as the key/value binding goes. Binding the value of the textField to a property and binding the enabled/disabled state of the button to another property made everything significantly simpler2.0ghz MacBook (Late 2008), Mac OS X (10.5.5)