Home > Software design >  How to programmatically hide the NSTextView's Find Bar?
How to programmatically hide the NSTextView's Find Bar?

Time:09-18

When the user starts a find action in a NSTextView control (for example by hitting ⌘ F on the keyboard), a find bar becomes visible, when property usesFindBar is set to true. That's great.

But how do I hide this bar programmatically?

CodePudding user response:

-(void)hideTextFinder{
 [txtFinder performAction:NSTextFinderActionHideFindInterface];
}

CodePudding user response:

Based on @apodidae helpful answer, I was able to get a working solution after adding a NSTextFinder object to the view controller in the storyboard, and connecting the client outlet of this object to the NSTextView control and findBarContainer to the scrollview of the said text view.

Then after connecting a newly created textFinder outlet variable in the view controller to the text finder object in the storyboard, this code line of @apodidae (translated to Swift) eventually works:

textFinder.performAction(.hideFindInterface)
  • Related