0

In my mainViewController i have a container. Inside this container are two ViewControllers. Now I made a function to switch between these two ViewControllers. This function is controlled by a pushbutton. This works as long as the pushbutton is inside the mainViewController. Now I want the pushButton to be inside the toolbar. It was possible to add a pushbutton to the toolbar manually. But I can´t connect it with the switch() function inside the main ViewController.

Thanks for any suggestion!

sophos
  • 107
  • 3
  • 8
  • It's not clear to me what you're asking. There's no such thing as "NSToolbarButton" (NSToolbarItem, or NSButton in a toolbar?). Are you trying to connect to an NSViewController, or an NSWindowController? What does "not possible" mean? What did you try, exactly? – Ssswift Jun 22 '17 at 18:54
  • In my mainViewController i have a container. Inside this container are two ViewControllers. Now I made a function to switch between these two ViewControllers. This function is controlled by a pushbutton. This works as long as the pushbutton is inside the mainViewController. Now I want the pushButton to be inside the toolbar. It was possible to add a pushbutton to the toolbar manually. But I can´t connect it with the `switch()` function. – sophos Jun 22 '17 at 19:06
  • Yes, it is an NSButton in a toolbar. I tried to make an @IBOutlet in my ViewController file. I think this is not possible, because it´s another class. So I tried to subclass NSWindowController to make the IBOutlet there... – sophos Jun 22 '17 at 19:15
  • These seem like great facts to put in the question, not just descriptions in a comment. – Ssswift Jun 22 '17 at 19:17
  • Any `constructive` suggestions? – sophos Jun 22 '17 at 19:30
  • 1
    Possible duplicate of [How to use NSToolBar in Xcode 6 and Storyboard?](https://stackoverflow.com/questions/24219441/how-to-use-nstoolbar-in-xcode-6-and-storyboard) – Willeke Jun 22 '17 at 20:41

1 Answers1

1

Select the first responder of the window controller scene, go to the Attributes Inspector and add the action.

Connect the action of the button in the toolbar to the first responder.

Willeke
  • 14,578
  • 4
  • 19
  • 47
  • Ok, I think I got it. Thank you very much. Last but not least, does this mean, i always have to have an (invisible(have to check if it´s possible)) button on my view controller? – sophos Jun 22 '17 at 21:30
  • No, you don't need a button. – Willeke Jun 22 '17 at 22:22