Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textDidChange vs controlTextDidChange

Tags:

objective-c

Can someone explain me why textDidChange isn't handling my delegate but controlTextDidChange works from NSTextField.

 - (void)controlTextDidChange:(NSNotification *)aNotification{
    NSBeep();
}

from

 - (void)textDidChange:(NSNotification *)aNotification{
    NSBeep();
}
like image 655
user1637802 Avatar asked Sep 01 '12 13:09

user1637802


2 Answers

controlTextDidChange: is the correct delegate method defined on NSTextField (inherited from NSControl).

textDidChange: is a method that, when called on NSTextField, makes it behave as if its text changed (including calling the above method). It is not a delegate method for you to implement.

It's a little inconsistent of Apple as they do have a textDidChange: delegate method on UISearchBarDelegate.

like image 132
Bryan Avatar answered Sep 18 '22 16:09

Bryan


textDidChange: Informs the delegate that the text object has changed its characters or formatting attributes.

I'm guessing that means its font (text attributes) changes, and not the text inputted.

like image 27
TheAmateurProgrammer Avatar answered Sep 20 '22 16:09

TheAmateurProgrammer