diff options
author | Malte E <malte.e@mailbox.org> | 2022-03-20 17:12:13 +0100 |
---|---|---|
committer | Malte E <malte.e@mailbox.org> | 2022-03-20 17:12:13 +0100 |
commit | 86a81307fb3b97a346b5a82fe04d6ddb45278b3e (patch) | |
tree | 324501de0840476b674b93475c6ba9d57d1c8bac | |
parent | Translated using Weblate (Indonesian) (diff) | |
download | nheko-86a81307fb3b97a346b5a82fe04d6ddb45278b3e.tar.xz |
make completer work with input method
-rw-r--r-- | resources/qml/MessageInput.qml | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index 8090cd99..34f35973 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -147,11 +147,24 @@ Rectangle { bottomPadding: 8 leftPadding: inputBar.showAllButtons? 0 : 8 focus: true + property string lastChar onTextChanged: { if (room) room.input.updateState(selectionStart, selectionEnd, cursorPosition, text); - forceActiveFocus(); + if (cursorPosition > 0) + lastChar = text.charAt(cursorPosition-1) + else + lastChar = '' + if (lastChar == '@') { + messageInput.openCompleter(selectionStart, "user"); + } else if (lastChar == ':') { + messageInput.openCompleter(selectionStart, "emoji"); + } else if (lastChar == '#') { + messageInput.openCompleter(selectionStart, "roomAliases"); + } else if (lastChar == "~") { + messageInput.openCompleter(selectionStart, "customEmoji"); + } } onCursorPositionChanged: { if (!room) @@ -187,14 +200,6 @@ Rectangle { messageInput.text = room.input.previousText(); } else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) { messageInput.text = room.input.nextText(); - } else if (event.key == Qt.Key_At) { - messageInput.openCompleter(selectionStart, "user"); - } else if (event.key == Qt.Key_Colon) { - messageInput.openCompleter(selectionStart, "emoji"); - } else if (event.key == Qt.Key_NumberSign) { - messageInput.openCompleter(selectionStart, "roomAliases"); - } else if (event.text == "~") { - messageInput.openCompleter(selectionStart, "customEmoji"); } else if (event.key == Qt.Key_Escape && popup.opened) { completer.completerName = ""; popup.close(); |