makeFirstResponder: and tab views
makeFirstResponder: and tab views
- Subject: makeFirstResponder: and tab views
- From: Graham Cox <email@hidden>
- Date: Mon, 06 Aug 2012 15:25:00 +1000
Run into a bug where if I have a number of NSTextFields in a window, and programatically switch the first responder of the window among these fields, it works fine, but if there is a NSTabView interposed between the fields and the window, they just cannot be set to be first responder programatically at all - it goes through the motions but it fails silently.
The text field has a blue focus ring, but there is no blinking cursor and typing results in a beep. The exact same code, without the tab view, works fine.
The field editor delegate causes the text field focus to shift every 4 characters:
- (void) controlTextDidChange:(NSNotification *)obj
{
NSTextField* control = [obj object];
NSString* text = [control stringValue];
if([text length] >= 4 )
{
NSString* shortStr = [[text substringToIndex:4] uppercaseString];
[control setStringValue:shortStr];
NSResponder* nextField = [control nextKeyView];
NSLog(@"got 4 characters: '%@', moving to field: %@", shortStr, nextField );
if([nextField acceptsFirstResponder])
[[self window] makeFirstResponder:nextField];
}
[self conditionallyEnableOK];
}
The 'self' here is the window controller and field editor's delegate.
I also tested to see whether the window returned YES or NO from makeFirstResponder: and it always returns YES, indicating success.
Has anyone else run into this? I've seen a few postings in the archives on apparently similar topics, and one suggestion is to delay the makeFirstResponder using -performSelector:... I have tried that but it doesn't work either. Some of these postings go back to 2004 - it's hard to believe such a painfully obvious bug would still be unfixed in 10.8
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden