summary refs log tree commit diff
path: root/resources/qml/MessageInput.qml
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-11-24 17:32:45 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-11-25 19:05:12 +0100
commit0cf556fa20b6cf9037517ed7bbbea5d3da820ce8 (patch)
tree91e213eeb96bcf023d43ea648af0396aa1854855 /resources/qml/MessageInput.qml
parentSplit completion model into header and source (diff)
downloadnheko-0cf556fa20b6cf9037517ed7bbbea5d3da820ce8.tar.xz
Mouse selection of completions
Diffstat (limited to 'resources/qml/MessageInput.qml')
-rw-r--r--resources/qml/MessageInput.qml15
1 files changed, 12 insertions, 3 deletions
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml
index 4f5b4b4c..7a033f5b 100644
--- a/resources/qml/MessageInput.qml
+++ b/resources/qml/MessageInput.qml
@@ -70,6 +70,11 @@ Rectangle {
 
                 property int completerTriggeredAt: -1
 
+                function insertCompletion(completion) {
+                    textArea.remove(completerTriggeredAt, cursorPosition);
+                    textArea.insert(cursorPosition, completion);
+                }
+
                 placeholderText: qsTr("Write a message...")
                 placeholderTextColor: colors.buttonText
                 color: colors.text
@@ -87,6 +92,7 @@ Rectangle {
                 }
                 onSelectionStartChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
                 onSelectionEndChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
+                // Ensure that we get escape key press events first.
                 Keys.onShortcutOverride: event.accepted = (completerTriggeredAt != -1 && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter))
                 Keys.onPressed: {
                     if (event.matches(StandardKey.Paste)) {
@@ -116,8 +122,7 @@ Rectangle {
                         popup.completerName = "";
                         popup.close();
                         if (currentCompletion) {
-                            textArea.remove(completerTriggeredAt, cursorPosition);
-                            textArea.insert(cursorPosition, currentCompletion);
+                            textArea.insertCompletion(currentCompletion);
                             event.accepted = true;
                             return ;
                         }
@@ -146,7 +151,11 @@ Rectangle {
                     }
                     target: TimelineManager
                 }
-                // Ensure that we get escape key press events first.
+
+                Connections {
+                    onCompletionClicked: textArea.insertCompletion(completion)
+                    target: popup
+                }
 
                 Completer {
                     id: popup