summaryrefslogtreecommitdiffstats
path: root/src/controls/Private/TextSingleton.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/controls/Private/TextSingleton.qml')
-rw-r--r--src/controls/Private/TextSingleton.qml24
1 files changed, 23 insertions, 1 deletions
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
+ }
+ }
+}