From 182f4c369aeef3b86e69a72def2e778b4ec755f0 Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Fri, 28 Sep 2012 12:57:13 +0200 Subject: [PATCH 1/2] Make sure the text field is visible before focus so the browser will not scroll without the NSScrollView knowing about it Issue #1675 and maybe a little of issue #1301 This fix will not work without pull request #1678 - Fixed scrollRectToVisible in CPView --- AppKit/CPTextField.j | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 07d52f7dd..93b77e769 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -513,6 +513,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]; From 7bf5f6f5a9da868adb16f3e551e521233fc9b830 Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Sat, 27 Oct 2012 15:13:57 +0200 Subject: [PATCH 2/2] Added scrollRectToVisible when CPTokenField becomeFirstResponder --- AppKit/CPTokenField.j | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index 8f45054e1..293ed994b 100755 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -310,6 +310,8 @@ var CPScrollDestinationNone = 0, if (CPTokenFieldInputOwner && [CPTokenFieldInputOwner window] !== [self window]) [[CPTokenFieldInputOwner window] makeFirstResponder:nil]; + [self scrollRectToVisible:[self bounds]]; + [self setThemeState:CPThemeStateEditing]; [self _updatePlaceholderState]; @@ -343,16 +345,19 @@ var CPScrollDestinationNone = 0, 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];