Re: NSTextField and key-events
Re: NSTextField and key-events
- Subject: Re: NSTextField and key-events
- From: Just van Rossum <email@hidden>
- Date: Sat, 21 Jun 2003 18:12:10 +0200
Patrick Gundlach wrote:
>
I am new to this list and new to cocoa development.
>
>
I'd like to create an interface with IB. My goal is to get an
>
NSTextField-alike field, where I get the keys the user types in
>
before he/she presses enter but with visual feedback. So something
>
like the search field in iTunes or Address Book. These applications
>
act before the user presses the enter key on the keyboard.
>
>
My first attempt was to create a subclass of NSTextField, say
>
EventTextField. I took a NSTextField in IB from the palette
>
(Views->NSTextField) and changed in the information window (Custom
>
Class) the NSTextField to EventTextField. This had no effect on the
>
outcome of the final application (with just this text field): I
>
created an initWithFrame:frame constructor, but this did not get
>
called. Same with methods like acceptFirstResponder and
>
keyDown:event.
>
>
So next try was to drag a CustomView (Cocoa-Containers) from the
>
palette and repeated the above (inside the custom view). This time
>
the initWithFrame initializer was called. So I implemented the method
>
acceptsFirstResponder that returns YES and keyDown:event, but the
>
latter one was never called.
>
>
What am I doing wrong? Am I heading in the right direction? Do I need
>
to change the fieldEditor? And how would I do this? Any hints? Or is
>
this question too trivial?
It took me a long time to find this, but what worked for me was to
implement NSControl's controlTextDidChange: delegate method. Set the
delegate of your text field to the object implementing
controlTextDidChange:. No subclass of NSTextField needed.
Just
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.