Created
January 10, 2010 17:59
-
-
Save BlairDuncan/273652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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