osx - Cocoa Storyboard Responder Chain -
The storyboard looks like a great solution for the coco app because I like the similar method in you iOS. However, there are a lot of logical emotions when breaking things in different view controllers, I'm not sure the window controller (toolbar button) or view the interval of menus to see the controllers who care about my app representative Is the first responder and receives the menu or toolbar functions, however, how can I access the controller that I want Need to get the land? Can you drill down only in the visual controller hierarchy, if so, you can get there from an app representative, because it is the first responder? Can you make the window controller first responsive instead? if so, how? In the storyboard? where?
Since this is a high level question, it does not make any difference, however, if you are thinking then I am using Swift for this project.
I'm not sure any " justified " is the way to resolve it However, I have come up with a solution that I will use for now. First few details
-
My app is a document based application so there is an example of a document in each window.
-
Documents using the app can act as the first responder and can forward the work I have done
< Li>
The document is capable of holding the top-level window controller and from there I need to see the controller to be able to drill down through the controller hierarchy.
So, in my window of window control, I do this:
override func windowDidLoad () {super.windowDidLoad () If self.contentViewController! = Zero {var vc = self.contentViewController! As NSSplitViewController bridesmaid innerSplitView = vc.splitViewItems [0] NSSplitViewItem bridesmaid innerSplitViewController = innerSplitView.viewController as NSSplitViewController God as layerCanvasSplitViewItem = innerSplitViewController.splitViewItems [1] as NSSplitViewItem self.layerCanvasViewController = layerCanvasSplitViewItem.viewController LayerCanvasViewController}} , I see the controller (which controls the underlined view below) and sets a local property in the window view controller.
So now, The events of the button or menu item can be sent directly to the document category which is in the response chain and therefore I get setup setup in the menu and toolbar items. In this way:
class-layer document: NSD document {@IBAction func addLayer (Sender: AnyObject) {var windowController = self.windowControllers [0] Main window controller window as controller Layer canvas viewer. Adlayer ()} // .. etc}
Since the Layer Kanvas Week controller was set as the property of the main window controller, when it was loaded I can access it and call me the necessary methods.
Comments
Post a Comment