[fbcocoa] Tabbing from combo box to text field

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Fri, 8 Jun 2012 08:15:04 -0400
Bernie,

Since objects are normally wired in the xib, you can try this programmatic construction.

Ken


compile as "Objective-C"

toolbox fn NSApplicationLoad = Boolean
fn NSApplicationLoad()

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

[window setAutorecalculatesKeyViewLoop:TRUE];

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];

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

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

NSComboBox *box4 = [[NSComboBox alloc] initWithFrame:NSMakeRect( 20, 180, 200, 23 )];
[tabItem1View addSubview:box4];
[box4 release];

[tab selectTabViewItem:[tab tabViewItemAtIndex:1]];
[tab selectTabViewItem:[tab tabViewItemAtIndex:0]];

[window makeKeyAndOrderFront:nil];
EndC

RunApplicationEventLoop()