[fbcocoa] Tabbing from combo box to text field

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2012 : Group Archive : Group : All Groups

From: Bernie <fbcocoa.bw@...>
Date: Fri, 8 Jun 2012 11:18:18 +0100
In the this example, hitting keyboard tab key shifts focus from the text field to a combo box embedded in a tab view. However, a further tab key press does not focus the text field (shift-tab works). When the combo box is not embedded in tab view, tabbing works as normal.

Clues?

'---------------
compile as "Objective-C"

toolbox fn NSApplicationLoad = Boolean
fn NSApplicationLoad()

BeginCCode
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect( 0, 360, 600, 400 ) 
     styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:YES];

NSTextField *fld = [[NSTextField alloc] initWithFrame:NSMakeRect( 20, 357, 300, 23 )];
[[window contentView] addSubview:fld];
[fld release];

NSTabView *tab = [[NSTabView alloc] initWithFrame:NSMakeRect( 12, 12, 576, 340 )];
NSRect tabContentRect = [tab contentRect];

NSTabViewItem *tabItem0 = [[NSTabViewItem alloc] initWithIdentifier:nil];
[tabItem0 setLabel:@"T0"];
NSView *tabItem0View =[[NSView alloc] initWithFrame:tabContentRect];
[tabItem0 setView:tabItem0View];
[tabItem0View release];
[tab addTabViewItem:tabItem0];
[tabItem0 release];

NSTabViewItem *tabItem1 = [[NSTabViewItem alloc] initWithIdentifier:nil];
[tabItem1 setLabel:@"T1"];
NSView *tabItem1View =[[NSView alloc] initWithFrame:tabContentRect];
[tabItem1 setView:tabItem1View];
[tabItem1View release];
[tab addTabViewItem:tabItem1];
[tabItem1 release];

[[window contentView] addSubview:tab];
[tab release];

NSComboBox *box = [[NSComboBox alloc] initWithFrame:NSMakeRect( 20, 220, 200, 23 )];
[tabItem0View addSubview:box];
[box release];

[window makeKeyAndOrderFront:nil];
EndC

RunApplicationEventLoop()
'---------------