diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2015-10-05 14:57:43 +0300 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2015-10-15 15:01:38 +0000 |
commit | c46ab8f76f6c32f0e415b01977bc51101da83a6d (patch) | |
tree | ac1c2e9c2736b4dfb2ec0f0a3f73aab9ce47f52c /examples | |
parent | 4b033851e66086e66af93940c134e1456b40d273 (diff) |
Add word reselection feature
This change adds support for word reselection.
By definition, word reselection means the ability to reselect any of the
existing words in the text by touching/clicking the word.
This change implements previously unused functionality provided by
QPlatformInputContext::invokeMethod(). This functionality is essential
for handling touch events inside a pre-edit text. The virtual keyboard
example app was previously blocking this function by overriding the
default touch handling for TextInput and TextEdit components.
Word reselection is currently implemented for the following input methods:
- HunspellInputMethod
- LipiInputMethod (by inheriting HunspellInputMethod)
- T9WriteInputMethod.
Change-Id: I66731e2d2831d4b3d43dac0503cd564ffb4d490f
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'examples')
3 files changed, 7 insertions, 25 deletions
diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextArea.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextArea.qml index 6906b86d..d4cb1cd1 100644 --- a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextArea.qml +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextArea.qml @@ -39,6 +39,10 @@ TextBase { color: "#D6D6D6" } } + MouseArea { + anchors.fill: parent + onClicked: textEdit.forceActiveFocus() + } TextEdit { id: textEdit @@ -55,7 +59,7 @@ TextBase { font.pixelSize: textArea.fontPixelSize selectionColor: Qt.rgba(1.0, 1.0, 1.0, 0.5) selectedTextColor: Qt.rgba(0.0, 0.0, 0.0, 0.8) + selectByMouse: true anchors { left: parent.left; right: parent.right; margins: 12 } - onActiveFocusChanged: if (!activeFocus) deselect() } } diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextBase.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextBase.qml index 5a26ce5a..6384e90c 100644 --- a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextBase.qml +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextBase.qml @@ -29,7 +29,6 @@ FocusScope { property int enterKeyAction: EnterKeyAction.None property string enterKeyText property bool enterKeyEnabled: enterKeyAction === EnterKeyAction.None || editor.text.length > 0 || editor.inputMethodComposing - property alias mouseParent: mouseArea.parent implicitHeight: editor.height + 12 @@ -51,6 +50,7 @@ FocusScope { id: previewText y: 8 + clip: true color: "#a0a1a2" visible: previewTextActive text: textBase.previewText @@ -58,25 +58,4 @@ FocusScope { anchors { left: parent.left; right: parent.right; margins: 12 } } - MouseArea { - id: mouseArea - - z: 1 - parent: textBase - anchors.fill: parent - onClicked: { - if (editor.inputMethodComposing) { - if (!Qt.inputMethod.visible) { - Qt.inputMethod.show() - return - } - Qt.inputMethod.commit() - } - var positionInEditor = mapToItem(editor, mouseX, mouseY) - var cursorPosition = editor.positionAt(positionInEditor.x, positionInEditor.y) - editor.cursorPosition = cursorPosition - editor.forceActiveFocus() - Qt.inputMethod.show() - } - } } diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextField.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextField.qml index 6f58aa24..c9ce4ee1 100644 --- a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextField.qml +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextField.qml @@ -32,7 +32,6 @@ TextBase { property int passwordMaskDelay: 1000 editor: textInput - mouseParent: flickable Flickable { id: flickable @@ -61,8 +60,8 @@ TextBase { font.pixelSize: textField.fontPixelSize selectionColor: Qt.rgba(0.0, 0.0, 0.0, 0.15) selectedTextColor: color + selectByMouse: true width: Math.max(flickable.width, implicitWidth)-2 - onActiveFocusChanged: if (!activeFocus) deselect() Binding { target: textInput |