PDA

View Full Version : How do I make it so editing text fields updates display as I type?




printz
May 4, 2013, 04:11 AM
It seems that text fields only do their actions when I press Return or focus out of them. Then I saw a simple binding example (a concept I still don't master) and the bound objects still only updated when I focused out. Yet I see lots of other applications where actions happen as soon as I type. How do I do it? By Key-Value Observing? I tried to observe NSTextField's stringValue, but it didn't work.



Red Menace
May 4, 2013, 09:11 AM
Take a look at the controlTextDidChange (https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSControl_Class/Reference/Reference.html#//apple_ref/doc/uid/20000073-SW22) delegate method and try updating your text from there.

printz
May 5, 2013, 12:45 AM
Thanks! I'll try it. It wasn't quite obvious, as I was bumping into other similarly named structures, which did nothing.