[Q] How to add "Find" feature for an NSTextView?
[Q] How to add "Find" feature for an NSTextView?
- Subject: [Q] How to add "Find" feature for an NSTextView?
- From: JongAm Park <email@hidden>
- Date: Wed, 09 Jul 2008 15:18:44 -0700
Hello.
I'm trying to write codes that searches a given text in an NSTextView.
Currently, a window has an NSSearchField and an NSTextView. Some text
will be loaded into the NSTextView and I expect users type into the
NSSearchField to search some words in the NSTextView.
I connected -(IBAction)searchSource:(id)sender to the NSSearchField.
-(IBAction)searchSource:(id)sender
{
NSString *searchString = [searchField stringValue];
NSRange stringRange = NSMakeRange(0, [searchString length] );
// xmlSourceView is the NSTextView in which the given string will be
searched
[xmlSourceView showFindIndicatorForRange:stringRange];
[xmlSourceView performFindPanelAction:self];
}
According to the document, the performFindPanelAction performs some
actions based on its tag.
However, there is no explanation how to set the tag.
Also, I tried "Command-F" to display a Find dialog box, but all of its
buttons are disabled.
I thought "Find" feature was automatically enabled without writing any
code before, but it doesn't work for me now.
Can anyone help me?
Thank you.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden