Disabling Buttons

Discussion in 'Mac Programming' started by MrC539, Nov 14, 2005.

  1. MrC539 macrumors newbie

    Nov 14, 2005
    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?

  2. caveman_uk Guest


    Feb 17, 2003
    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.
  3. MrC539 thread starter macrumors newbie

    Nov 14, 2005

Share This Page