75 Previously we had code here which would force the input to regain focus if the input lost focus without the CPTextField having actually lost first responder status. This typically happened because the user clicked away from the input in the browser, without clicking on something that could become the first responder. In the browser, clicking outside of an input blurs it, but in Cocoa and Cappuccino it does not (unless you actually click something that will become the first responder).

76

77 That refocusing code has now been removed because we simply prevent the default action on clicks in the browser instead, which combined with the fix in 58d5d7d7, successfully prevents unintentional focus loss in (at least) Safari 9.1.1, Chrome 51 and Safari for iOS 9.3 when you click outside of a text field.

78

79 Now we can still lose focus unexpectedly: this is when the 'done' button is tapped on the virtual keyboard of a mobile device. In this case we actually do want to resign first responder status, because that is what the done button should do (and if we did not the keyboard would go away and then immediately come back which looks dumb and isn't what the user wanted).

601// As long as we are the first responder we need to monitor the key status of our window.

602 [self _setObserveWindowKeyNotifications:YES];

603

604 _isEditing = NO;

605

606if ([[self window] isKeyWindow] && [self isEditable])

607return [self _becomeFirstKeyResponder];

608

609return YES;

610 }

611

612/*

613 A text field can be the first responder without necessarily being the focus of keyboard input. For example, it might be the first responder of window A but window B is the main and key window. It's important we don't put a focused input field into a text field in a non-key window, even if that field is the first responder, because the key window might also have a first responder text field which the user will expect to receive keyboard input.

614

615 Since a first responder but non-key window text field can't receive input it should not even look like an active text field (Cocoa has a "slightly active" text field look it uses when another window is the key window, but Cappuccino doesn't today.)

616

617 It's also possible for a text field to be non-editable but selectable in which case it can also become the first responder -

618 this is what allows text to be copied from it.

619*/

620 - (BOOL)_becomeFirstKeyResponder

621 {

622// If the text field is still not completely on screen, refuse to become

623// first responder, because the browser will scroll it into view out of our control.

624if (![self _isWithinUsablePlatformRect])

625return NO;

626

627// A selectable but non-editable text field may be the first responder, but never the