• 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: Send action when textDidChange
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Send action when textDidChange


  • Subject: Re: Send action when textDidChange
  • From: Stéphane Sudre <email@hidden>
  • Date: Tue, 26 Jun 2001 13:55:37 +0200

On mardi, juin 26, 2001, at 06:36 AM, Ivan Myrvold wrote:

My application have a search field and a table. When a user types something in the search field, the table should update based on the search value.

I solved this by adding the window controller as an observer of the NSControlTextDidChangeNotification message. This works great. But the window also have two other fields, and the NSControlTextDidChangeNotification message is posted also when these fields are edited.

To solve this side effect, it would be nice to have the text field send an action when the text in its field changes. As I have understood from the documentation, the default is that an action message is sent when the return key is pressed.

So how do I change this? I read the docs for NSControl, NSActionCell and NSCell without finding the answer to this.

Why not make your window controller a delegate of the NSTextField, implement the - (void)controlTextDidChange:(NSNotification *)aNotification; and test that the value return for the key @"NSFieldEditor" is the NSTextField you need to observe.

- (void)controlTextDidChange:(NSNotification *)aNotification;

Sent by the default notification center to the delegate when the text in the receiving control (usually a text field, form, or NSMatrix with editable cells) changes. The name of the notification aNotification is always NSControlTextDidChangeNotification. Use the key @"NSFieldEditor" to obtain the field editor from aNotification's userInfo dictionary. If the delegate implements this method, it's automatically registered to receive this notification.


References: 
 >Send action when textDidChange (From: Ivan Myrvold <email@hidden>)

  • Prev by Date: Library loading policy on Mac OS X with Cocoa
  • Next by Date: Re: Send action when textDidChange
  • Previous by thread: Re: Send action when textDidChange
  • Next by thread: Re: Send action when textDidChange
  • Index(es):
    • Date
    • Thread