Skip to content

Instantly share code, notes, and snippets.

@BlairDuncan
Created January 10, 2010 17:59
Show Gist options
  • Save BlairDuncan/273652 to your computer and use it in GitHub Desktop.
Save BlairDuncan/273652 to your computer and use it in GitHub Desktop.
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
[theWindow orderFront:self];
var detailsWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 200, 200) styleMask:CPClosableWindowMask | CPTitledWindowMask];
[detailsWindow center];
[detailsWindow setHasShadow:YES];
var button = [[CPButton alloc] initWithFrame:CGRectMake(100, 150, 60, 24)];
[button setTitle:@"Cancel"];
[button setTarget:self];
[button setAction:@selector(handleCancel:)];
[[detailsWindow contentView] addSubview:button];
var textField = [CPTextField textFieldWithStringValue:@"" placeholder:@"Type \"1234\"" width:120];
[textField setDelegate:self];
[[detailsWindow contentView] addSubview:textField];
[detailsWindow orderFront:self];
[CPApp runModalForWindow:detailsWindow];
}
- (void)handleCancel:(id)sender
{
[[sender window] close];
[CPApp stopModal];
}
- (void) controlTextDidEndEditing:(CPNotification)aNotification
{
if ([[aNotification object] objectValue] === @"1234")
{
var alert = [[CPAlert alloc] init];
[alert setMessageText:@"A message here"];
[alert setAlertStyle:CPInformationalAlertStyle];
[alert addButtonWithTitle:@"OK"]
[alert runModal];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment