7

I have a button and a NSTextView in my application. I want that the NSTextView gets focus when the button is pushed. If I then enter text through keyboard it should go in the NSTextView.

What code should i put in the button's action method?

AmaltasCoder
  • 1,123
  • 3
  • 17
  • 35

1 Answers1

11

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

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