diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index d833c9900..b292a5554 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -543,6 +543,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); */ - (void)_becomeFirstKeyResponder { + // Make sure the text field is visible so the browser will not scroll without the NSScrollView knowing about it. + [self scrollRectToVisible:[self bounds]]; + [self setThemeState:CPThemeStateEditing]; [self _updatePlaceholderState]; diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index 856107604..090119065 100755 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -330,6 +330,8 @@ CPTokenFieldDeleteButtonType = 1; // As long as we are the first responder we need to monitor the key status of our window. [self _setObserveWindowKeyNotifications:YES]; + [self scrollRectToVisible:[self bounds]]; + if ([[self window] isKeyWindow]) [self _becomeFirstKeyResponder]; @@ -371,16 +373,19 @@ CPTokenFieldDeleteButtonType = 1; element.style.width = CGRectGetWidth(contentRect) + "px"; element.style.height = [font defaultLineHeightForFont] + "px"; - [_tokenScrollView documentView]._DOMElement.appendChild(element); - window.setTimeout(function() { - element.focus(); - CPTokenFieldInputOwner = self; - }, 0.0); + [_tokenScrollView documentView]._DOMElement.appendChild(element); - //post CPControlTextDidBeginEditingNotification - [self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]]; + //post CPControlTextDidBeginEditingNotification + [self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]]; + + window.setTimeout(function() + { + element.focus(); + CPTokenFieldInputOwner = self; + }, 0.0); + }, 0.0); [[[self window] platformWindow] _propagateCurrentDOMEvent:YES];