I have encountered a strange (to me) problem with keyboard loop. I have
several buttons placed as subviews of two NSBox-es, which are in turn
located on a NSView. I set the keyboard loop properly (multiple times
checked) in IB but whenever I reach the last button in one NSBox,
instead of jumping to the first button in the second box I get the message:
*** -[NSBox refusesFirstResponder]: selector not recognized [self =
0x35ed30]
Sure NSBox shouldn't become the FirstResponder! In fact, it shouldn't
even be touched as nextKeyView is set in IB to be the next button and
NOT the NSBox...
I use the following custom code to switch between the buttons:
- (BOOL)nextControl
{
NSControl *aControl = self;
while (([(NSControl *)[aControl nextKeyView] refusesFirstResponder]) ||
([(NSControl *)[aControl nextKeyView] isEnabled] == NO))
{
aControl = (NSControl *)[aControl nextKeyView];
if (aControl == self)
return FALSE;
}
return [[self window] makeFirstResponder:(NSControl *)[aControl
nextKeyView]];
}
I use the custom code because I want it to work regardless of the
CTRL-F7 settings. The funny thing is that it already worked until I
started placing the controls on top of different views and seemingly
spoiled something ;-) Does anyone have a guess (or knowledge!) what is
wrong here?
> I have encountered a strange (to me) problem with keyboard loop. I have
> several buttons placed as subviews of two NSBox-es, which are in turn
> located on a NSView. I set the keyboard loop properly (multiple times
> checked) in IB but whenever I reach the last button in one NSBox,
> instead of jumping to the first button in the second box I get the message:
>
> *** -[NSBox refusesFirstResponder]: selector not recognized [self =
> 0x35ed30]
>
> Sure NSBox shouldn't become the FirstResponder! In fact, it shouldn't
> even be touched as nextKeyView is set in IB to be the next button and
> NOT the NSBox...
>
> [...] The funny thing is that it already worked until I
> started placing the controls on top of different views and seemingly
> spoiled something ;-) Does anyone have a guess (or knowledge!) what is
> wrong here?
OK. While moving controls to different views I disconnected the window's
"initialFirstResponder" outlet. Reconnecting it with CTRL-drag (menu
function dosn't work here - understandable but a warning wouldn't hurt
IMHO) solved the problem, even if I am not sure why lack of this
connection actually causes it.