Focus on NSTextView

I have a button and an NSTextView in my application. I want NSTextView to get focus when a button is clicked. If I then enter text through the keyboard, it should go into NSTextView.

What code should I enter in the button action method?

+6
source share
1 answer

Assuming you have an output called textView , this should work:

 - (IBAction)buttonClicked:(id)sender { NSButton *button = sender; NSWindow *window = [button window]; [window makeFirstResponder:textView]; } 
+9
source

Source: https://habr.com/ru/post/887705/


All Articles