summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/controls/Private/TextInputWithHandles.qml2
-rw-r--r--src/controls/Private/TextSingleton.qml24
-rw-r--r--src/controls/TextArea.qml1
3 files changed, 26 insertions, 1 deletions
diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml
index cace83f64..59ba971e8 100644
--- a/src/controls/Private/TextInputWithHandles.qml
+++ b/src/controls/Private/TextInputWithHandles.qml
@@ -38,6 +38,7 @@
**
****************************************************************************/
import QtQuick 2.2
+import QtQuick.Controls.Private 1.0
TextInput {
id: input
@@ -71,6 +72,7 @@ TextInput {
selectionHandle.position = (selectionStart !== cursorPosition) ? selectionStart : selectionEnd
blockRecursion = false
}
+ TextSingleton.updateSelectionItem(input)
}
function activate() {
diff --git a/src/controls/Private/TextSingleton.qml b/src/controls/Private/TextSingleton.qml
index 7bccdd552..3ff89af01 100644
--- a/src/controls/Private/TextSingleton.qml
+++ b/src/controls/Private/TextSingleton.qml
@@ -33,4 +33,26 @@
pragma Singleton
import QtQuick 2.2
-Text {}
+Text {
+ /**
+ selectionItem is the item that currently has a text selection. On some platforms
+ (iOS) you can select text without activating the input field. This means that
+ selectionItem can be different from item with active focus on those platforms.
+ */
+ property Item selectionItem: null
+
+ function updateSelectionItem(item)
+ {
+ // Convenience function to check if we should transfer or
+ // remove selectionItem status from item.
+ var selection = item.selectionStart !== item.selectionEnd
+ if (item === selectionItem) {
+ if (!selection)
+ selectionItem = null
+ } else if (selection) {
+ if (selectionItem)
+ selectionItem.select(selectionItem.cursorPosition, selectionItem.cursorPosition)
+ selectionItem = item
+ }
+ }
+}
diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml
index 415098380..6db196b62 100644
--- a/src/controls/TextArea.qml
+++ b/src/controls/TextArea.qml
@@ -787,6 +787,7 @@ ScrollView {
blockRecursion = false
}
ensureVisible(cursorRectangle)
+ TextSingleton.updateSelectionItem(area)
}
function ensureVisible(rect) {