Disable/Enable NSButton if NSTextfield is empty or not

Viewed 17869

I´m newbie with cocoa. I have a button and a textField in my app. I want the button disabled when the textfield is empty and enabled when the user type something.

Any point to start? Any "magic" binding in Interface Builder?

Thanks

[EDITED]

I´ve tried to set the appDelegate as the NSTextfield´s delegate and added this method (myTextfield and myButton are IBOutlets):

- (void)textDidChange:(NSNotification *)aNotification
{
    if ([[myTextField stringValue]length]>0) {
        [myButton setEnabled: YES];
    }
    else {
        [myButton setEnabled: NO];
    }
}

But nothing happens...

4 Answers
Related