Skip to content

Instantly share code, notes, and snippets.

@boucher
Created January 12, 2010 18:09
Show Gist options
  • Save boucher/275416 to your computer and use it in GitHub Desktop.
Save boucher/275416 to your computer and use it in GitHub Desktop.
/*
* AppController.j
* keyviewloop2
*
* Created by Ross Boucher on January 12, 2010.
* Copyright 2010, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
LABEL1 = label;
[label setStringValue:@"Hello World!"];
[label setFont:[CPFont boldSystemFontOfSize:24.0]];
[label setBezeled:YES];
[label sizeToFit];
[label setEditable:YES];
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[label setCenter:[contentView center]];
[contentView addSubview:label];
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
LABEL2 = label;
[label setStringValue:@"Hello World!"];
[label setFont:[CPFont boldSystemFontOfSize:24.0]];
[label setBezeled:YES];
[label sizeToFit];
[label setEditable:YES];
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[label setCenter:CGPointMake([contentView center].x, [contentView center].y + 40)];
[contentView addSubview:label];
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
LABEL3 = label;
[label setStringValue:@"Hello World!"];
[label setFont:[CPFont boldSystemFontOfSize:24.0]];
[label setBezeled:YES];
[label sizeToFit];
[label setEditable:YES];
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[label setCenter:CGPointMake([contentView center].x, [contentView center].y - 40)];
[contentView addSubview:label];
[theWindow orderFront:self];
// THESE LINES MANIPULATE THE KEY VIEW LOOP
[theWindow setAutorecalculatesKeyViewLoop:NO];
[LABEL1 setNextKeyView:LABEL3];
[LABEL3 setNextKeyView:LABEL1];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment