From 8c7ca2d9139c767e3b950850274d4d69eea664e9 Mon Sep 17 00:00:00 2001
From: Berthold Krevert <berthold.krevert@basyskom.com>
Date: Mon, 12 May 2014 17:07:39 +0200
Subject: [PATCH] Fix selection handling in texteditor example

Task-number: QTBUG-31784
Change-Id: I7122abbfd346edd85f17c54dfde37db93a1ba0fc
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
---
 examples/quick/controls/texteditor/qml/main.qml | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/examples/quick/controls/texteditor/qml/main.qml b/examples/quick/controls/texteditor/qml/main.qml
index 1a66afa58..26e22e984 100644
--- a/examples/quick/controls/texteditor/qml/main.qml
+++ b/examples/quick/controls/texteditor/qml/main.qml
@@ -272,16 +272,19 @@ ApplicationWindow {
                 implicitWidth: 150
                 model: Qt.fontFamilies()
                 property bool special : false
-                onCurrentTextChanged: {
-                    if (special == false || currentIndex != 0)
-                        document.fontFamily = currentText
+                onActivated: {
+                    if (special == false || index != 0) {
+                        document.fontFamily = textAt(index)
+                    }
                 }
             }
             SpinBox {
                 id: fontSizeSpinBox
+                activeFocusOnPress: false
                 implicitWidth: 50
                 value: 0
-                onValueChanged: document.fontSize = value
+                property bool valueGuard: true
+                onValueChanged: if (valueGuard) document.fontSize = value
             }
             Item { Layout.fillWidth: true }
         }
@@ -307,7 +310,11 @@ ApplicationWindow {
         selectionStart: textArea.selectionStart
         selectionEnd: textArea.selectionEnd
         Component.onCompleted: document.fileUrl = "qrc:/example.html"
-        onFontSizeChanged: fontSizeSpinBox.value = document.fontSize
+        onFontSizeChanged: {
+            fontSizeSpinBox.valueGuard = false
+            fontSizeSpinBox.value = document.fontSize
+            fontSizeSpinBox.valueGuard = true
+        }
         onFontFamilyChanged: {
             var index = Qt.fontFamilies().indexOf(document.fontFamily)
             if (index == -1) {
-- 
GitLab