Re: Find panel
Re: Find panel
- Subject: Re: Find panel
- From: Ivan Myrvold <email@hidden>
- Date: Mon, 2 Aug 2004 11:28:31 +0200
Further testing with my code shows that when I start up the app for the
first time, it works as it should. But if I type in another search
string in my NSSearchField, using command-G still uses the first search
string. If I do a switch between Mail.app and back, the new search
string is in effect.
I know that in both cases it goes through the searchAction code, as I
put the
NSLog(@"Find: %@", [pb stringForType:NSStringPboardType]);
as the last line in the action method, and I got the following output
in Console.app:
2004-08-02 11:15:10.079 AstConsole[1421] Find: 216
2004-08-02 11:15:18.961 AstConsole[1421] Find: 216.
2004-08-02 11:15:19.267 AstConsole[1421] Find: 216.2
2004-08-02 11:15:19.509 AstConsole[1421] Find: 216.20
2004-08-02 11:15:19.830 AstConsole[1421] Find: 216.207
2004-08-02 11:15:41.807 AstConsole[1421] Find: Act
2004-08-02 11:15:47.963 AstConsole[1421] Find: Acti
2004-08-02 11:15:48.186 AstConsole[1421] Find: Actio
2004-08-02 11:15:48.475 AstConsole[1421] Find: Action
2004-08-02 11:16:20.692 AstConsole[1421] Find: Actio
2004-08-02 11:16:30.886 AstConsole[1421] Find: Action
The" 216.207" was the first search string I used, and everything worked
perfect, as this is the first search after startup of the app. But the
"Action" search string wasn't used until I switched to another cocoa
app and back again. But as you see, the NSFindPboard already have the
string.
Isn't this really strange?
Ivan
Pe 2. aug. 2004 kl. 08.00 skrev Ivan Myrvold:
>
More clues:
>
>
1. I write in a search word in NSSearchField ("hello")
>
2. I tabs into the NSTextView, and open the find panel. It is empty.
>
3. I click in the Mail.app and opens the find panel. Voila, it contains
>
"hello"
>
4. I click in my app again, and opens the find panel, and now it also
>
contains "hello"
>
>
If I now write in a new search word in my app, the find panel still
>
contains "hello". I have to go through Mail.app (or another Cocoa app)
>
to get t changed.
>
There must be another method call I am missing. Here is the whole
>
NSSearch field action method:
>
>
- (IBAction)searchAction:(id)sender {
>
if ([[sender stringValue] length] > 0) {
>
NSRange textRange = [[self consoleView] rangeOfString:[sender
>
stringValue]];
>
NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSFindPboard];
>
>
[ocommandsTextView setSelectedRange:textRange];
>
[ocommandsTextView scrollRangeToVisible:textRange];
>
[pb declareTypes:[NSArray arrayWithObject:NSStringPboardType]
>
owner:nil];
>
[pb setString:[sender stringValue] forType:NSStringPboardType];
>
}
>
}
>
>
Ivan
>
>
Pe 2. aug. 2004 kl. 06.58 skrev Ivan Myrvold:
>
>
> This works for the first search string I type in the NSSearchField.
>
> The next search string I type in, is not used. Instead, the find panel
>
> contains the first search string in the find field.
>
>
>
> Ivan
>
>
>
> Pe 1. aug. 2004 kl. 23.25 skrev Glenn Andreas:
>
>
>
>> On Sunday, August 01, 2004, at 04:02PM, Ivan Myrvold
>
>> <email@hidden> wrote:
>
>>
>
>>> I tried the following in the NSSearchField action method:
>
>>>
>
>>> NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSFindPboard];
>
>>> [pb setString:[sender stringValue] forType:NSStringPboardType];
>
>>>
>
>>
>
>> In IDEKit, I do:
>
>>
>
>> NSPasteboard *pasteboard = [NSPasteboard
>
>> pasteboardWithName:NSFindPboard];
>
>> [pasteboard declareTypes:[NSArray
>
>> arrayWithObject:NSStringPboardType] owner:nil];
>
>> [pasteboard setString:[self findString]
>
>> forType:NSStringPboardType];
>
>>
>
>> and it seems to work correctly - I'm guessing just adding the
>
>> declareTypes:owner: should do it...
>
>> _______________________________________________
>
>> 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.
>
> _______________________________________________
>
> 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.
>
>
>
>
>
>
>
Ivan C Myrvold
>
OrtopediService AS
>
Mob. 913 16 356
>
Tlf. 38 14 45 93
>
_______________________________________________
>
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.
_______________________________________________
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.