• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextField and key-events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >NSTextField and key-events (From: Patrick Gundlach <email@hidden>)

  • Prev by Date: Re: NSTextField and key-events
  • Next by Date: NSSound & autorelease
  • Previous by thread: Documentation (was :NSTextField and key-events)
  • Next by thread: NSSound & autorelease
  • Index(es):
    • Date
    • Thread