diff options
Diffstat (limited to 'resources/qml/MessageInput.qml')
-rw-r--r-- | resources/qml/MessageInput.qml | 15 |
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 |