mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-17 08:01:27 +00:00
Refs #1001. Make it easy to test text field cut/paste behaviour.
This commit is contained in:
@@ -52,7 +52,7 @@
|
||||
[contentView addSubview:shadowLabel];
|
||||
[contentView addSubview:championOfLightLabel];
|
||||
|
||||
var jumpLabel = [CPTextField labelWithTitle:@"The text of these text fields should not move when a field becomes the first responder."];
|
||||
var jumpLabel = [CPTextField labelWithTitle:@"The text of these text fields should not move ('jump') when a field becomes the first responder. Labels on the right should replicate the input."];
|
||||
|
||||
[jumpLabel sizeToFit];
|
||||
[jumpLabel setFrameOrigin:CGPointMake(15, 150)];
|
||||
@@ -63,15 +63,24 @@
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
var size = 10 + 3 * i,
|
||||
textField = [CPTextField textFieldWithStringValue:@"Size " + size placeholder:@"Size " + size width:200];
|
||||
textField = [CPTextField textFieldWithStringValue:@"Size " + size placeholder:@"Size " + size width:200],
|
||||
echoField = [CPTextField labelWithTitle:""];
|
||||
|
||||
[textField setFont:[CPFont systemFontOfSize:size]];
|
||||
[textField sizeToFit];
|
||||
[textField setFrameOrigin:CGPointMake(15, y)];
|
||||
textField.echoField = echoField;
|
||||
[contentView addSubview:textField];
|
||||
|
||||
[echoField setFont:[CPFont systemFontOfSize:size]];
|
||||
[echoField setStringValue:[textField stringValue]];
|
||||
[echoField sizeToFit];
|
||||
[echoField setFrameOrigin:CGPointMake(CGRectGetMaxX([textField frame]) + 15, CGRectGetMidY([textField frame]) - CGRectGetHeight([echoField frame]) / 2.0)];
|
||||
[contentView addSubview:echoField];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:CPControlTextDidChangeNotification object:textField];
|
||||
|
||||
y = CGRectGetMaxY([textField frame]) + 6;
|
||||
|
||||
[contentView addSubview:textField];
|
||||
}
|
||||
|
||||
[theWindow orderFront:self];
|
||||
@@ -111,4 +120,12 @@
|
||||
[sender setEditable:NO];
|
||||
}
|
||||
|
||||
- (void)textDidChange:(CPNotification)aNotification
|
||||
{
|
||||
var changedField = [aNotification object];
|
||||
|
||||
[changedField.echoField setStringValue:[changedField stringValue]];
|
||||
[changedField.echoField sizeToFit];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user