1
votes

Suppose there is a window which has two NSTextViews in it, and each of them uses the findBar.

The problem is that after closing one find bar (finishing the finding) the cursor jumps to the other textView, i.e. the focus does not return the the textView for which the find operation originated.

Please, does anyone know how to make it return to the original view?

This is a screenshot of one simple setup:

enter image description here

3
Can you paste your code?So that it will be easy to identify the problem. - Hussain Shabbir
@HussainShabbir There is not much of a source code, it's basically just two textviews in Interface Builder / Xcode. See the edit for a screenshot. - Ecir Hana
Are using single IBOutlet for both NSTextView ?? - Hussain Shabbir
@HussainShabbir No, I just placed there the two textviews... - Ecir Hana

3 Answers

2
votes

You can assign the nextKeyView property in StoryBoards (see image below) to assign where you want to the focus to "jump", otherwise, if you need to assign the nextKeyView property programmatically (when the view is initialized), you can do so using the nextKeyView property available via the NSView class. Both methods are hinted at below:

1. Assign the nextKeyView programmatically via this property

@property(assign) NSView *nextKeyView;


2. Or you can assign the nextKeyView in storyboards


Or you can assign the nextKeyView in storyboards

Hope this helps!

1
votes

Set the nextKeyView property of the text field back to the original view.

1
votes

You can create the subclass of textview and mention the same inside your interface builder->Custom class and inside your custom textview class override the below method:-

-(BOOL)becomeFirstResponder
{
    return YES;
}