Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MrC539

macrumors newbie
Original poster
Nov 14, 2005
8
0
Hi everyone,

I'm fairly new to Obj-C/Cocoa, and I've been working on a simple app. One thing I would like to add is to make the default button to be disabled unless two textfields have something written in them. I've searched Google a bit, and it seems I need to use "bindings" but the sites don't explain how to use bindings very well. Could someone point me in the right direction on disabling the default button unless 2 text fields are filled?

Thanks.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
You don't necessarily need to use bindings as you can use NSButton's setEnabled: method.

Personally I'd set up my controller as a delegate of both the NSTextField's and catch the

- (void)controlTextDidChange:(NSNotification *)aNotification

delegate method. In this I'd check that both the NSTextFields have something in them and if they do setEnabled on the NSButton appropriately.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.