Re: Send action when textDidChange
Re: Send action when textDidChange
- Subject: Re: Send action when textDidChange
- From: "John C. Randolph" <email@hidden>
- Date: Tue, 26 Jun 2001 03:11:52 -0700
On Monday, June 25, 2001, at 09:36 PM, 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.
All you need to do to solve the side effect is look at the notification
object and see which field caused the notification.
- (void)controlTextDidChange:(NSNotification *)aNotification
{
if ([aNotification object] == mySearchTextField)
// do something.
}
-jcr
[Objc retain];