NSTextFinder set search string and clear visual feedback programmatically
Date : March 29 2020, 07:55 AM
help you fix your problem I found my answers, so for others here's how to do it. First you need an instance of NSTextFinder so you can control it. We set that up in code. textFinder = [[NSTextFinder alloc] init];
[textFinder setClient:textView];
[textFinder setFindBarContainer:[textView enclosingScrollView]];
[textView setUsesFindBar:YES];
[textView setIncrementalSearchingEnabled:YES];
[textFinder cancelFindIndicator];
[textFinder noteClientStringWillChange];
// change the NSFindPboard NSPasteboardTypeString
NSPasteboard* pBoard = [NSPasteboard pasteboardWithName:NSFindPboard];
[pBoard declareTypes:[NSArray arrayWithObjects:NSPasteboardTypeString, NSPasteboardTypeTextFinderOptions, nil] owner:nil];
[pBoard setString:@"new search" forType:NSStringPboardType];
NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSTextFinderCaseInsensitiveKey, [NSNumber numberWithInteger:NSTextFinderMatchingTypeContains], NSTextFinderMatchingTypeKey, nil];
[pBoard setPropertyList:options forType:NSPasteboardTypeTextFinderOptions];
// put the new search string in the find bar
[textFinder cancelFindIndicator];
[textFinder performAction:NSTextFinderActionSetSearchString];
[textFinder performAction:NSTextFinderActionShowFindInterface]; // make sure the find bar is showing
[myWindow makeFirstResponder:outlineView];
[myWindow makeFirstResponder:textView];
|
NSTextFinder action on NSTextView
Date : March 29 2020, 07:55 AM
|
NSTextFinder and Regular Expression search
Date : March 29 2020, 07:55 AM
|
How do I get NSTextFinder to show up
Date : March 29 2020, 07:55 AM
|
NSTextFinder + programmatically changing the text in NSTextView
Tag : cocoa , By : user96271
Date : March 29 2020, 07:55 AM
|