views:

30

answers:

2

I have an application thad loads in plugins that have their own UI. There is an IBOutlet called ContainerView in my AppDelegate. When the plugin loads, it puts its own view (that is stored in a xib in the plugin bundle) into the Container view like so
[ContainerView addSubview:viewFromPlugin];

When the view loads, everything is fine but when I press tab the only controls that get any focus are ones outside of the ContainerView and none of them inside it get focus.
I've tried setting the container view as the initialFirstResponder and I've tried hooking up the nextKeyView from the last button in the tab order to the ContainerView.

Thanks.

A: 

Did you try calling the becomeFirstResponder method on your ContainerView?

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIResponder_Class/Reference/Reference.html#//apple_ref/occ/instm/UIResponder/becomeFirstResponder

UIView classes inherit from UIResponder.

Michael Lamb
The questioner is asking about Cocoa, not Cocoa Touch. Note that he is asking about how to implement tabbing between views, plus the mentions of the `nextKeyView` property, which only NSViews have. There is no need to explicitly handle tabbing; Cocoa does that for you, so sending any message like this is unnecessary. Even if it were, sending a responder a `becomeFirstResponder` message is wrong in Cocoa; you tell the window to do that for you.
Peter Hosey
+1  A: 

I've tried setting the container view as the initialFirstResponder and I've tried hooking up the nextKeyView from the last button in the tab order to the ContainerView.

Is that what you want to do? Make the container view the key view? It doesn't sound like it; it sounds like you want the plug-in view (or a view within it) to become the key view.

This section of the Apple documentation explains all of the different aspects of the key view loop. I believe you'll want to either set the nextKeyView of the container view as well as the view before it, or override the container view's nextValidKeyView method—possibly both. You might also try setting the previous view's nextKeyView directly to the plug-in view's nextValidKeyView, skipping over the container view entirely.

Peter Hosey
I was able to override nextKeyView for the ContainerView and get it to tab into the plugin's view.To make it so I tabbed out of the plugin view, I subclassed my last view and again overrode nextKeyView and made it break out of the plugin view (using a series of superview calls). It works but it seems like a little bit too much of a hack. Any ideas?
Randall
Actually, the real fix for this was to click a little checkbox in Interface Builder that said "Auto Recalculates View Loop"
Randall