From e9cd1654574ae0753134da3e1a98d78e807a7d57 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 23 Feb 2023 10:33:45 +0100 Subject: [PATCH] Fix Escape shortcut in RoomPage Since commit eee93e0f1, the ChatBar has a conflicting shortcut that takes precedence even when it doesn't do anything, so that the Escape shortcut of RoomPage is never actually invoked any more. Fix this by using Keys.onShortcutOverride() instead in ChatBar and accepting the event only when it actually cancelled something. So if you're writing a reply, the first time pressing Escape cancels the reply and the second one calls the RoomPage shortcut that goes to the RoomListPage. --- src/qml/Component/ChatBox/ChatBar.qml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qml/Component/ChatBox/ChatBar.qml b/src/qml/Component/ChatBox/ChatBar.qml index 75c9fa4c2..f529a4aaf 100644 --- a/src/qml/Component/ChatBox/ChatBar.qml +++ b/src/qml/Component/ChatBox/ChatBar.qml @@ -185,6 +185,13 @@ QQC2.Control { repeatTimer.stop() } } + Keys.onShortcutOverride: { + // Accept the event only when there was something to cancel. Otherwise, let the event go to the RoomPage. + if (cancelButton.visible && event.key === Qt.Key_Escape) { + cancelButton.action.trigger(); + event.accepted = true; + } + } Loader { id: paneLoader @@ -270,7 +277,6 @@ QQC2.Control { currentRoom.chatBoxAttachmentPath = ""; root.forceActiveFocus() } - shortcut: "Escape" } QQC2.ToolTip.text: text QQC2.ToolTip.visible: hovered