From 1f264852083ea1c3245a9b11fba3d3f16ae4f319 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Sun, 29 Dec 2024 10:54:47 +0100 Subject: [PATCH] ChatBar: Remove explicit Keys.onDeletePressed handler Key-specific handlers, such as Key.onDeletePressed implicitly accept the event. This means that the entire logic for the delete key must be reimplemented, and e.g. Ctrl+Delete to delete the previous *word* was missed. Since all it has to do is handle the typing notification and format bar, just use the already existing Keys.onPressed handler (which does *not* accept the event) and add a case for Delete alongside Backspace. --- src/chatbar/ChatBar.qml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/chatbar/ChatBar.qml b/src/chatbar/ChatBar.qml index e75ba10e0..1987b61ba 100644 --- a/src/chatbar/ChatBar.qml +++ b/src/chatbar/ChatBar.qml @@ -237,20 +237,6 @@ QQC2.Control { onFormattingSelected: _private.formatText(format, selectionStart, selectionEnd) } - Keys.onDeletePressed: { - if (selectedText.length > 0) { - remove(selectionStart, selectionEnd); - } else { - remove(cursorPosition, cursorPosition + 1); - } - if (textField.text == selectedText || textField.text.length <= 1) { - root.currentRoom.sendTypingNotification(false); - repeatTimer.stop(); - } - if (quickFormatBar.visible) { - quickFormatBar.close(); - } - } Keys.onEnterPressed: event => { const controlIsPressed = event.modifiers & Qt.ControlModifier; if (completionMenu.visible) { @@ -289,7 +275,7 @@ QQC2.Control { completionMenu.decrementIndex(); } else if (event.key === Qt.Key_Down && completionMenu.visible) { completionMenu.incrementIndex(); - } else if (event.key === Qt.Key_Backspace) { + } else if (event.key === Qt.Key_Backspace || event.key === Qt.Key_Delete) { if (textField.text == selectedText || textField.text.length <= 1) { root.currentRoom.sendTypingNotification(false); repeatTimer.stop();