Merge pull request #1005 from maltee1/fix_input_method

Fix input method
This commit is contained in:
DeepBlueV7.X 2022-03-22 03:56:01 +01:00 committed by GitHub
commit dfb34a6c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 13 deletions

View File

@ -124,7 +124,7 @@ Rectangle {
completerTriggeredAt = pos;
completer.completerName = type;
popup.open();
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition));
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition)+messageInput.preeditText);
}
function positionCursorAtEnd() {
@ -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-1, "user");
} else if (lastChar == ':') {
messageInput.openCompleter(selectionStart-1, "emoji");
} else if (lastChar == '#') {
messageInput.openCompleter(selectionStart-1, "roomAliases");
} else if (lastChar == "~") {
messageInput.openCompleter(selectionStart-1, "customEmoji");
}
}
onCursorPositionChanged: {
if (!room)
@ -162,9 +175,13 @@ Rectangle {
popup.close();
if (popup.opened)
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition));
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition)+messageInput.preeditText);
}
onPreeditTextChanged: {
if (popup.opened)
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition)+messageInput.preeditText);
}
onSelectionStartChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
// Ensure that we get escape key press events first.
@ -187,14 +204,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();
@ -215,8 +224,10 @@ Rectangle {
return;
}
}
room.input.send();
event.accepted = true;
if (!Qt.inputMethod.visible) {
room.input.send();
event.accepted = true;
}
} else if (event.key == Qt.Key_Tab && (event.modifiers == Qt.NoModifier || event.modifiers == Qt.ShiftModifier)) {
event.accepted = true;
if (popup.opened) {