From 96c2f123b432a3fca96efb1262d3099ded15e455 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 15 Feb 2021 13:45:08 +0100 Subject: [PATCH] feat(StatusChatInput): make text input formatting work via shortcuts Closes #1803 --- ui/shared/status/StatusChatInput.qml | 52 +++++++++++++++++----------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/ui/shared/status/StatusChatInput.qml b/ui/shared/status/StatusChatInput.qml index a65a813326..a870a3891a 100644 --- a/ui/shared/status/StatusChatInput.qml +++ b/ui/shared/status/StatusChatInput.qml @@ -683,6 +683,7 @@ Rectangle { if (messageInputField.selectedText.trim() !== "") { let x = event.x - (textFormatMenu.width / 2) textFormatMenu.popup(x, -messageInputField.height-2) + messageInputField.forceActiveFocus(); } } @@ -718,34 +719,43 @@ Rectangle { } } } - Action { - shortcut: StandardKey.Bold - onTriggered: wrapSelection("**") + + Shortcut { + enabled: messageInputField.activeFocus + sequence: StandardKey.Bold + onActivated: wrapSelection("**") } - Action { - shortcut: StandardKey.Italic - onTriggered: wrapSelection("*") + Shortcut { + enabled: messageInputField.activeFocus + sequence: StandardKey.Italic + onActivated: wrapSelection("*") } - Action { - shortcut: "Ctrl+Shift+Alt+C" - onTriggered: wrapSelection("```") + Shortcut { + enabled: messageInputField.activeFocus + sequence: "Ctrl+Shift+Alt+C" + onActivated: wrapSelection("```") } - Action { - shortcut: "Ctrl+Shift+C" - onTriggered: wrapSelection("`") + Shortcut { + enabled: messageInputField.activeFocus + sequence: "Ctrl+Shift+C" + onActivated: wrapSelection("`") } - Action { - shortcut: "Ctrl+Alt+-" - onTriggered: wrapSelection("~~") + Shortcut { + enabled: messageInputField.activeFocus + sequence: "Ctrl+Alt+-" + onActivated: wrapSelection("~~") } - Action { - shortcut: "Ctrl+Shift+X" - onTriggered: wrapSelection("~~") + Shortcut { + enabled: messageInputField.activeFocus + sequence: "Ctrl+Shift+X" + onActivated: wrapSelection("~~") } - Action { - shortcut: "Ctrl+Meta+Space" - onTriggered: emojiBtn.clicked() + Shortcut { + enabled: messageInputField.activeFocus + sequence: "Ctrl+Meta+Space" + onActivated: emojiBtn.clicked() } + } Rectangle {