From 3bb8c0d3f2115765b519f795a2898456bf31924b Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Mon, 25 Jul 2011 13:17:35 +1000 Subject: [PATCH] Scroll correctly when cursorPosition is changed within onTextChanged. Emit textChanged() before adjusting size and scroll positions otherwise the calculations will be based on the cursor position before it's moved in handler and because the cursor position won't ultimately have changed there won't be a follow up cursorPositionChanged() signal to trigger a second set of calculation. Task-number: QTBUG-19912 Reviewed-by: Martin Jones (cherry picked from commit bb11b53bedb8e239b9439b4a3fc3320e35c2de57) Conflicts: src/declarative/graphicsitems/qdeclarativetextinput.cpp Change-Id: I579bc3fe6c80766dfadfbc9dbd46144607bf7b03 Reviewed-on: http://codereview.qt.nokia.com/2058 Reviewed-by: Qt Sanity Bot Reviewed-by: Andrew den Exter --- src/declarative/items/qsgtextinput.cpp | 4 ++-- .../graphicsitems/qdeclarativetextinput.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/items/qsgtextinput.cpp b/src/declarative/items/qsgtextinput.cpp index a150b7e..e73237e 100644 --- a/src/declarative/items/qsgtextinput.cpp +++ b/src/declarative/items/qsgtextinput.cpp @@ -1219,12 +1219,12 @@ void QSGTextInput::selectionChanged() void QSGTextInput::q_textChanged() { Q_D(QSGTextInput); + emit textChanged(); + emit displayTextChanged(); updateSize(); d->determineHorizontalAlignment(); d->updateHorizontalScroll(); updateMicroFocus(); - emit textChanged(); - emit displayTextChanged(); if(hasAcceptableInput() != d->oldValidity){ d->oldValidity = hasAcceptableInput(); emit acceptableInputChanged(); diff --git a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp index 582e3c7..9a291ea 100644 --- a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp @@ -1948,12 +1948,12 @@ void QDeclarative1TextInput::selectionChanged() void QDeclarative1TextInput::q_textChanged() { Q_D(QDeclarative1TextInput); + emit textChanged(); + emit displayTextChanged(); updateSize(); d->determineHorizontalAlignment(); d->updateHorizontalScroll(); updateMicroFocus(); - emit textChanged(); - emit displayTextChanged(); if(hasAcceptableInput() != d->oldValidity){ d->oldValidity = hasAcceptableInput(); emit acceptableInputChanged(); -- 1.7.2.5