From 541f5b89484faa3c878ffb8707b33cebaa5197f0 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Tue, 14 Sep 2010 15:31:31 -0400 Subject: [PATCH] Test editable text field text selection in a modal window. --- Tests/Manual/CPTextField/AppController.j | 30 ++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Tests/Manual/CPTextField/AppController.j b/Tests/Manual/CPTextField/AppController.j index 56c081216..d30fafd22 100644 --- a/Tests/Manual/CPTextField/AppController.j +++ b/Tests/Manual/CPTextField/AppController.j @@ -11,6 +11,7 @@ @implementation AppController : CPObject { + CPWindow aWindow; } - (void)applicationDidFinishLaunching:(CPNotification)aNotification @@ -36,8 +37,33 @@ [theWindow orderFront:self]; - // Uncomment the following line to turn on the standard menu bar. - //[CPMenu setMenuBarVisible:YES]; + aWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(150, 300, 400, 150) styleMask:CPTitledWindowMask | CPClosableWindowMask | CPDocModalWindowMask]; + [aWindow setTitle:@"Text Field in a Window"] + + contentView = [aWindow contentView]; + + textField = [CPTextField textFieldWithStringValue:"Select me!" placeholder:"" width:0]; + label = [[CPTextField alloc] initWithFrame:CGRectMake(15, 15, 360, 30)]; + [label setLineBreakMode:CPLineBreakByWordWrapping]; + + [label setStringValue:"Select the field and double click it to select text. The text should become selected. Then hit enter to continue."]; + [contentView addSubview:label]; + + [textField setFrame:CGRectMake(15, CGRectGetMaxY([label frame]) + 10, 300, 30)]; + + [textField setEditable:YES]; + + [textField setTarget:self]; + [textField setAction:@selector(modalAction:)]; + + [contentView addSubview:textField]; + + [CPApp beginSheet:aWindow modalForWindow:theWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; +} + +- (void)modalAction:(id)sender +{ + [CPApp endSheet:aWindow returnCode:0]; } - (void)textAction:(id)sender