Fixed: arrow cursor when the cursor is hover a CPTextField

Previously, when the cursor was hover a CPTextField the cursor was an arrow till we selected the textField.
Now when the cursor is hover a CPTextField, and if this textField is enabled and editable or selectable we show the selecting cursor. This is the default behavior in Cocoa as well.

Updated manual test Tests/Manual/CPTextField/
This commit is contained in:
Alexandre Wilhelm
2014-10-24 23:26:48 -07:00
parent 2e3c658bc8
commit 3e5a6986f9
2 changed files with 22 additions and 0 deletions
+17
View File
@@ -31,6 +31,7 @@
@global CPApp
@global CPStringPboardType
@global CPCursor
@protocol CPTextFieldDelegate <CPControlTextEditingDelegate>
@@ -981,6 +982,22 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
return [[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES];
}
- (void)mouseEntered:(CPEvent)anEvent
{
[super mouseEntered:anEvent];
if ([self isEnabled] && ([self isSelectable] || [self isEditable]))
[[CPCursor IBeamCursor] set];
}
- (void)mouseExited:(CPEvent)anEvent
{
[super mouseExited:anEvent];
// Make sure to have the arrow cursor when leaving a textField
[[CPCursor arrowCursor] set];
}
- (void)keyUp:(CPEvent)anEvent
{
if (!([self isEnabled] && [self isEditable]))
+5
View File
@@ -50,8 +50,13 @@
[shadowLabel setFrame:CGRectMake(15, CGRectGetMaxY([textField frame]) + 10, 300, 18)];
[championOfLightLabel setFrame:CGRectMake(15, CGRectGetMaxY([shadowLabel frame]) + 2, 300, 18)];
var selectableLabel = [CPTextField labelWithTitle:@"This text should be selectable and you should see the selectable cursor."];
[selectableLabel setSelectable:YES];
[selectableLabel setFrame:CGRectMake(15, CGRectGetMaxY([championOfLightLabel frame]) + 8, 600, 18)];
[contentView addSubview:shadowLabel];
[contentView addSubview:championOfLightLabel];
[contentView addSubview:selectableLabel];
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."];