Disabling Buttons

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

  1. MrC539
    Expand Collapse
    macrumors newbie

    Joined:
    Nov 14, 2005
    #1
    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.
     
  2. caveman_uk
    Expand Collapse
    Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #2
    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
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Nov 14, 2005

Share This Page