NSSearchField In Modal Dialog;
NSSearchField In Modal Dialog;
- Subject: NSSearchField In Modal Dialog;
- From: Matt Budd (Madentec) <email@hidden>
- Date: Tue, 7 Dec 2004 10:12:25 -0700
Hello,
I'm using an NSSearchField in a modal dialog. My modal dialog is called in this way:
if (_oPreferenceController == nil) {
_oPreferenceController = [[PreferenceController alloc] initWithDictionaryRef: _oDictionary];
}
//Launch the dictionary-view window as a modal dialog (not using the -showWindow method of the controller)
[NSApp beginSheet: [_oPreferenceController window]
modalForWindow: nil
modalDelegate: nil
didEndSelector: nil
contextInfo: nil
];
[NSApp runModalForWindow: [_oPreferenceController window]];
//Dialog is running at this point -- will return execution to the next line
[NSApp endSheet: [_oPreferenceController window]];
The problem is that I've set the NSSearchField to send it's action on every keystroke (turning off the "Sends whole search string" option in IB). However, I don't get my action called on every keystroke. I think it might have something to do with the way that I am calling the modal dialog and some event-loop stuff.
So then I tried to fake it out by in my preference controller, registering for the NSTextDidChangeNotification. This works, and my notification handler gets called for each keystroke, but there is no way to identify which control it is coming from. Usually the -object method of the NSNotification for that particular notification contains the object that was the source of the notification. And usually I compare this to an IBOutlet that I've set up in IB. But I try the following code and neither work:
- (void)handleTextDidChange: (NSNotification *)poNotification
{
if ([[poNotification object] cell] == schCustomSuggestion) {
NSLog(@"is equal to IBOutlet");
} else if ([[poNotification object] cell] == [schCustomSuggestion cell]) {
NSLog(@"is equal to IBOutlet's cell");
} else {
NSLog(@"This is actually a NSTextView: %@", [poNotification object]);
}
}
It always end up in the third part of this if-else statement.
So how do I get notification of each keystroke from a NSSearchField in a modal dialog. Is there a better way to a modal dialog that prevents this problem (so I could just use the plain target/action pattern)? Or is there a way to get the NSTextView that causes the notification from the IBOutlet pointing to the NSSearchField.
- Matt
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden