diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 89de8be0a..6cd39a6fb 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -31,6 +31,7 @@ @global CPApp @global CPStringPboardType +@global CPCursor @protocol CPTextFieldDelegate @@ -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])) diff --git a/Tests/Manual/CPTextField/AppController.j b/Tests/Manual/CPTextField/AppController.j index 52cbb591b..389cf3c8e 100644 --- a/Tests/Manual/CPTextField/AppController.j +++ b/Tests/Manual/CPTextField/AppController.j @@ -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."];