summary refs log tree commit diff
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2021-08-21 18:12:43 +0000
committerGitHub <noreply@github.com>2021-08-21 18:12:43 +0000
commit24e81e3848d0e304dbf41e6e399a0efd8cff67d6 (patch)
tree6ff0936fa50fe176ae2e9dfa65c3412302208b93
parentSimplify message delegate size calculation a bit (diff)
parentAvoid completer jitter before closing (diff)
downloadnheko-24e81e3848d0e304dbf41e6e399a0efd8cff67d6.tar.xz
Merge pull request #686 from thombles/popup-selection
Fix minor display bugs with emoji completer
-rw-r--r--resources/qml/MessageInput.qml22
1 files changed, 11 insertions, 11 deletions
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml

index 7fb09684..7599036e 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml
@@ -93,7 +93,7 @@ Rectangle { TextArea { id: messageInput - property int completerTriggeredAt: -1 + property int completerTriggeredAt: 0 function insertCompletion(completion) { messageInput.remove(completerTriggeredAt, cursorPosition); @@ -134,8 +134,7 @@ Rectangle { return ; room.input.updateState(selectionStart, selectionEnd, cursorPosition, text); - if (cursorPosition <= completerTriggeredAt) { - completerTriggeredAt = -1; + if (popup.opened && cursorPosition <= completerTriggeredAt) { popup.close(); } if (popup.opened) @@ -145,7 +144,7 @@ Rectangle { 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. - Keys.onShortcutOverride: event.accepted = (completerTriggeredAt != -1 && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter)) + Keys.onShortcutOverride: event.accepted = (popup.opened && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter)) Keys.onPressed: { if (event.matches(StandardKey.Paste)) { room.input.paste(false); @@ -165,18 +164,20 @@ Rectangle { } 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(cursorPosition, "user"); + messageInput.openCompleter(selectionStart, "user"); popup.open(); } else if (event.key == Qt.Key_Colon) { - messageInput.openCompleter(cursorPosition, "emoji"); + messageInput.openCompleter(selectionStart, "emoji"); popup.open(); } else if (event.key == Qt.Key_NumberSign) { - messageInput.openCompleter(cursorPosition, "roomAliases"); + messageInput.openCompleter(selectionStart, "roomAliases"); popup.open(); } else if (event.key == Qt.Key_Escape && popup.opened) { - completerTriggeredAt = -1; popup.completerName = ""; + popup.close(); event.accepted = true; + } else if (event.matches(StandardKey.SelectAll) && popup.opened) { + popup.completerName = ""; popup.close(); } else if (event.matches(StandardKey.InsertParagraphSeparator)) { if (popup.opened) { @@ -266,7 +267,6 @@ Rectangle { if (room) messageInput.append(room.input.text()); - messageInput.completerTriggeredAt = -1; popup.completerName = ""; messageInput.forceActiveFocus(); } @@ -285,8 +285,8 @@ Rectangle { Completer { id: popup - x: messageInput.completerTriggeredAt >= 0 ? messageInput.positionToRectangle(messageInput.completerTriggeredAt).x : 0 - y: messageInput.completerTriggeredAt >= 0 ? messageInput.positionToRectangle(messageInput.completerTriggeredAt).y - height : 0 + x: messageInput.positionToRectangle(messageInput.completerTriggeredAt).x + y: messageInput.positionToRectangle(messageInput.completerTriggeredAt).y - height } Connections {