Key input from NSTextField

Samurai

Registered
I have an app mostly done except for one thing. I cannot figure out how to tell if I get an CR from a NSTextField. I can setup notifiation if editing ends, but I need a CR only and not a tab out of a field.

I really need to know how I can get every key even from a NSTextField into my application.


Thanks.
 
Override the keydown: method of NSResponder, which NSTextField inherits from. Or, in Interface Builder, set it to send action "Only on Enter" rather than "On end editing" - this is likely to be simpler for what you want.
 
Thanks for the suggestions.

Overriding keydown is exactly that I wanted to do a tried. I can succesfully do this with a view but not a NSTextField. In fact I have not had any luck subclassing NSTextField at all. In inteface builder I subclass NSTextField to MyTextField, assign my text field to this custom class and create the class files in project builder. No matter what I do I get runtime errors such as "ObjCJava WARNING:
jobjc_jvm_newObject(): constructor with signature (Ljava/io/InputStream;)V on class java/io/ObjectInputStream failed (should morph the java exception)..." Funny, I can create other custom subclasses fine just not NSTextField.

As for your suggestion to go into IB and send "Only on Enter", this sounds good but how do I do this? In days of reading up on this I never saw any reference to doing this or even the term "Only on Enter". I looked again today and can't figure out how to do this. Can you point me in the right direction ?
 
Back
Top