Skip to content

Instantly share code, notes, and snippets.

@lsinger
Created December 26, 2009 20:23
Show Gist options
  • Save lsinger/264033 to your computer and use it in GitHub Desktop.
Save lsinger/264033 to your computer and use it in GitHub Desktop.
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
CPView _contentView;
CPTextField _nicknameTextField;
CPPanel _nicknameHUD;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask];
_contentView = [theWindow contentView];
var bounds = [_contentView bounds];
_messages = [];
[_contentView setBackgroundColor:[CPColor colorWithHexString:@"A8C0D1"]];
var _nicknameHUD = [[CPPanel alloc] initWithContentRect:CGRectMake(185, 200, 225, 125) styleMask:CPHUDBackgroundWindowMask];
[_nicknameHUD setTitle:@"Please enter a nickname"];
[_nicknameHUD setFloatingPanel:YES];
[_nicknameHUD orderFront:self];
var panelContentView = [_nicknameHUD contentView],
centerX = (CGRectGetWidth([panelContentView bounds]) - 135.0) / 2.0;
// add the nickname textfield
_nicknameTextField = [CPTextField roundedTextFieldWithStringValue:@"" placeholder:@"Nickname" width:150.0];
[_nicknameTextField setFrameOrigin:CGPointMake(37, 20)];
[_nicknameTextField setAction:@selector(saveNickname)];
[panelContentView addSubview:_nicknameTextField];
// add the save nickname button
var saveNicknameButton = [[CPButton alloc] initWithFrame:CGRectMake(85, 60, 50, 24)];
[saveNicknameButton setTitle:@"OK"];
[saveNicknameButton setTarget:self];
[saveNicknameButton setAction:@selector(saveNickname)];
[panelContentView addSubview:saveNicknameButton];
[theWindow makeFirstResponder: _nicknameTextField];
[theWindow orderFront: self];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment