Re: Send action when textDidChange
Re: Send action when textDidChange
- Subject: Re: Send action when textDidChange
- From: Ivan Myrvold <email@hidden>
- Date: Tue, 26 Jun 2001 13:47:58 +0400
What I want to accomplish, is to have an action method in
MyWindowController sent a notification when a user changes a text field.
So I have done this:
In method registerNotificationObservers in MyWindowController:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateaurtable:)
name:NSControlTextDidChangeNotification object:nil];
As I said, this works, but what I want to accomplish, is to have an
action message sent to the method I wired up as an action in IB when the
text is changed. As my application works today, the action method is
called only when the user press return, I want it called for every time
he presses a key inside the text field.
Ivan
On Tuesday, June 26, 2001, at 11:41 AM, Carlos Weber wrote:
>
On Monday, June 25, 2001, at 06:36 , 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.
>
>
What if you just registered as an observer of the
>
NSControlTextDidChangeNotification message for your particular search
>
field? The method
>
>
- (void)addObserver:(id)anObserver
>
selector:(SEL)aSelector
>
name:(NSString *)notificationName
>
object:(id)anObject
>
>
allows you to specify anObject as the sole source of the notifications,
>
or pass nil if you want to receive the notification from all sources.
>
>
Or did I misunderstand what you are trying to accomplish?