make completer work with input method
This commit is contained in:
parent
2cff6088eb
commit
86a81307fb
@ -147,11 +147,24 @@ Rectangle {
|
|||||||
bottomPadding: 8
|
bottomPadding: 8
|
||||||
leftPadding: inputBar.showAllButtons? 0 : 8
|
leftPadding: inputBar.showAllButtons? 0 : 8
|
||||||
focus: true
|
focus: true
|
||||||
|
property string lastChar
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if (room)
|
if (room)
|
||||||
room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
|
room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
|
||||||
|
|
||||||
forceActiveFocus();
|
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: {
|
onCursorPositionChanged: {
|
||||||
if (!room)
|
if (!room)
|
||||||
@ -187,14 +200,6 @@ Rectangle {
|
|||||||
messageInput.text = room.input.previousText();
|
messageInput.text = room.input.previousText();
|
||||||
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
|
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
|
||||||
messageInput.text = room.input.nextText();
|
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) {
|
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
||||||
completer.completerName = "";
|
completer.completerName = "";
|
||||||
popup.close();
|
popup.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user