From 2490a8332a290faa0c3d4ef766ec2d5fd4e721d7 Mon Sep 17 00:00:00 2001 From: alcomposer Date: Thu, 14 Nov 2024 12:15:59 +1030 Subject: [PATCH 1/2] Use the commandID to dismiss the callout box also, no need for a dismiss() lambda --- Source/Sidebar/CommandInput.h | 8 ++++---- Source/Statusbar.cpp | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Source/Sidebar/CommandInput.h b/Source/Sidebar/CommandInput.h index 6ea6205c6..b27a5055f 100644 --- a/Source/Sidebar/CommandInput.h +++ b/Source/Sidebar/CommandInput.h @@ -180,10 +180,11 @@ class CommandInput final public: CommandInput(PluginEditor* editor) : editor(editor) { + // We need to set the target for the command manager, otherwise it will default to PlugDataApp and fail to find CommandID + editor->commandManager.setFirstCommandTarget(editor); // Get the application command id key to toggle show/hide of the command prompt // We need to know this as the command prompt gets keyboard focus // So the command prompt needs to dismiss itself when the CommandID key is pressed - // And we want to make sure the user can set this shortcut auto* keyMappings = editor->commandManager.getKeyMappings(); auto keyPresses = keyMappings->getKeyPressesAssignedToCommand(CommandIDs::ShowCommandInput); commandIDToggleShowKey = keyPresses.getFirst(); @@ -732,8 +733,8 @@ class CommandInput final return true; } else if (key.getKeyCode() == commandIDToggleShowKey.getKeyCode()) { - dismiss(); - return true; + editor->commandManager.invokeDirectly(CommandIDs::ShowCommandInput, false); + return true; } return false; } @@ -829,7 +830,6 @@ class CommandInput final public: - std::function dismiss = [](){}; std::function onDismiss = [](){}; static inline const UnorderedSet allAtoms = { "floatbox", "symbolbox", "listbox", "gatom" }; diff --git a/Source/Statusbar.cpp b/Source/Statusbar.cpp index 4e5d477f3..70f9aeddb 100644 --- a/Source/Statusbar.cpp +++ b/Source/Statusbar.cpp @@ -1260,23 +1260,21 @@ Statusbar::~Statusbar() void Statusbar::showCommandInput() { - if (commandInputCallout) + if (commandInputCallout) { + commandInputCallout->dismiss(); return; + } auto commandInput = std::make_unique(editor); auto rawCommandInput = commandInput.get(); auto& callout = editor->showCalloutBox(std::move(commandInput), commandInputButton->getScreenBounds().removeFromRight(22)); - commandInputCallout = (&callout); - - rawCommandInput->dismiss = [callout_ = SafePointer(&callout)](){ - if (callout_) { - callout_->dismiss(); - } - }; + commandInputCallout = &callout; rawCommandInput->onDismiss = [this](){ // If the mouse is not over the button when callout is closed, the button doesn't know it needs to repaint + // This can cause paint glitches on the button if the cursor is not over the button when callout is closed + // So we call repaint on the button when the callout is destroyed commandInputButton->repaint(); }; } From cc2a3005a49c020b9bf187295a0f70668332d9d5 Mon Sep 17 00:00:00 2001 From: alcomposer Date: Thu, 14 Nov 2024 12:25:15 +1030 Subject: [PATCH 2/2] Change command input CommandID keymapping to same as PD & MAX: ctrl+shift+m --- Source/PluginEditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 11254c950..43388d94f 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -1259,7 +1259,7 @@ void PluginEditor::getCommandInfo(CommandID const commandID, ApplicationCommandI } case CommandIDs::ShowCommandInput: { result.setInfo("Toggle Command Input", "Enables or disables the command input", "View", 0); - result.addDefaultKeypress(KeyPress::F3Key, ModifierKeys::noModifiers); + result.addDefaultKeypress(77, ModifierKeys::shiftModifier | ModifierKeys::ctrlModifier); result.setActive(true); break; }