Regarding connection to First Responder, I think I'm still missing a step. I have a menu item I want to connect to First Responder so that, as I understand it, I can then make an outlet and action for that item in my view controller (stop me if I'm wrong there). Here's what I did:
* select the menu item in the storyboard's outline table * go to the Connections Inspector and find the "Sent Actions" * There's a button in there that VO identifies as "connection action, AX button". I locked the mouse down on that. * I went back to my outline, located First Responder in my application scene, put VO on the unlabeled button on to its right, and released the mouse. A connection appeared in the Connections Inspector for First Responder, so that seems to have worked. * Note: a new window appeared, with a massive list of actions, from "superscript" to "cut" to "spellcheck", and tons more. VO read a few unlabeled buttons in here, but mostly it just found objects that were "unknown". Enter did nothing, so I eventually had to press escape. I still don't know what that window was for or if I was supposed to do something with it. * If I'm following yesterday's discussion, I should now be able to make an IBOutlet in my view controller for the menu item, since said menu item is now hooked to First Responder. When I did, it refused to connect. * In case I misunderstood, and I have to keep the outlet in AppDelegate but can put just the action anywhere, I connected the menu item to an outlet in AppDelegate and then tried dragging from the "new action AX button" in the menu item's Connections Inspector to my IBAction method, in the view controller. Unfortunately, the mouse simply refused to route to the button I needed to drag, yet it routed to any other connection button I tried. * Finally, I tried dragging from the button in the view controller source code to the storyboard outline, as described in a previous message. That failed to make a connection.
As I said, I have to be missing some key step to getting this working. I've spent a long time googling all this stuff, but there's very little out there that I could find. My best hope was a 2014 WWDC video, but not seeing the code the presenter was talking about, not to mention the segue lines and other visual cues he relied on, I didn't follow much of it. On Sep 2, 2015, at 12:26 AM, Quincey Morris < email@hidden> wrote:
On Sep 1, 2015, at 20:51 , Alex Hall < email@hidden> wrote:
My problem now--and this also lets us get back to Xcode usage--is connecting these to the First Responder.
The process you described earlier, using VO to “drag” from the button in the margin of the source code action method to the menu item, sounded correct, but didn’t work work because you were inadvertently crossing a scene boundary. It *should* work if the action method is in the right place.
I was also able to go in the other direction, dragging from the “action” button in the Sent Actions section of the Connections inspector when the menu item was selected, to the source code of the action method (the actual code this time, not the button next to it).
Neither of these things involve the Control key, but they require displaying two different panes in the Xcode window.
However, as I said before, it’s all a bit murky. Sometimes IB refuses to make a connection that seems like it should be acceptable, and I can never work out why. Hitting the screen with a heavy blunt object might make you feel better.
Handing off control would be good, that way I could use appDelegate as a kind of entry point but keep most of my logic (and outlets) in the view controllers where they belong. Hopefully I can work out how to do just that; I imagine the appDelegate has a way of accessing the view controller, it's just a matter of finding out how.
If you put the action method in the app delegate — the intuitive answer in your case — there’s no good “how”. The view controller pretty much has to call a method of the app delegate to tell the app delegate who it is. (You can’t have a NIB outlet from the app delegate to the view controller for the same scene boundary reasons we already talked about.)
Or, if your window organization is fixed, the app delegate can find the current main window, then find its window controller, then find its content view controller, which you may or may not find hack-ish.
Or, you can have the app delegate keep track of window controller(s), delegate the action to the window controller, which in turn delegates to a suitable view controller. This is probably the most elegant approach, but there’s a fair amount of housekeeping to set this up.
|