Skip to content

Commit 92cd84c

Browse files
Merge pull request #1940 from alcomposer/command-dismiss-fix
Use the commandID to dismiss the callout box also, no need for a dism…
2 parents 8119967 + cc2a300 commit 92cd84c

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

Source/PluginEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ void PluginEditor::getCommandInfo(CommandID const commandID, ApplicationCommandI
12591259
}
12601260
case CommandIDs::ShowCommandInput: {
12611261
result.setInfo("Toggle Command Input", "Enables or disables the command input", "View", 0);
1262-
result.addDefaultKeypress(KeyPress::F3Key, ModifierKeys::noModifiers);
1262+
result.addDefaultKeypress(77, ModifierKeys::shiftModifier | ModifierKeys::ctrlModifier);
12631263
result.setActive(true);
12641264
break;
12651265
}

Source/Sidebar/CommandInput.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,11 @@ class CommandInput final
180180
public:
181181
CommandInput(PluginEditor* editor) : editor(editor)
182182
{
183+
// We need to set the target for the command manager, otherwise it will default to PlugDataApp and fail to find CommandID
184+
editor->commandManager.setFirstCommandTarget(editor);
183185
// Get the application command id key to toggle show/hide of the command prompt
184186
// We need to know this as the command prompt gets keyboard focus
185187
// So the command prompt needs to dismiss itself when the CommandID key is pressed
186-
// And we want to make sure the user can set this shortcut
187188
auto* keyMappings = editor->commandManager.getKeyMappings();
188189
auto keyPresses = keyMappings->getKeyPressesAssignedToCommand(CommandIDs::ShowCommandInput);
189190
commandIDToggleShowKey = keyPresses.getFirst();
@@ -732,8 +733,8 @@ class CommandInput final
732733
return true;
733734
}
734735
else if (key.getKeyCode() == commandIDToggleShowKey.getKeyCode()) {
735-
dismiss();
736-
return true;
736+
editor->commandManager.invokeDirectly(CommandIDs::ShowCommandInput, false);
737+
return true;
737738
}
738739
return false;
739740
}
@@ -829,7 +830,6 @@ class CommandInput final
829830

830831
public:
831832

832-
std::function<void()> dismiss = [](){};
833833
std::function<void()> onDismiss = [](){};
834834

835835
static inline const UnorderedSet<String> allAtoms = { "floatbox", "symbolbox", "listbox", "gatom" };

Source/Statusbar.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,23 +1260,21 @@ Statusbar::~Statusbar()
12601260

12611261
void Statusbar::showCommandInput()
12621262
{
1263-
if (commandInputCallout)
1263+
if (commandInputCallout) {
1264+
commandInputCallout->dismiss();
12641265
return;
1266+
}
12651267

12661268
auto commandInput = std::make_unique<CommandInput>(editor);
12671269
auto rawCommandInput = commandInput.get();
12681270
auto& callout = editor->showCalloutBox(std::move(commandInput), commandInputButton->getScreenBounds().removeFromRight(22));
12691271

1270-
commandInputCallout = (&callout);
1271-
1272-
rawCommandInput->dismiss = [callout_ = SafePointer(&callout)](){
1273-
if (callout_) {
1274-
callout_->dismiss();
1275-
}
1276-
};
1272+
commandInputCallout = &callout;
12771273

12781274
rawCommandInput->onDismiss = [this](){
12791275
// If the mouse is not over the button when callout is closed, the button doesn't know it needs to repaint
1276+
// This can cause paint glitches on the button if the cursor is not over the button when callout is closed
1277+
// So we call repaint on the button when the callout is destroyed
12801278
commandInputButton->repaint();
12811279
};
12821280
}

0 commit comments

Comments
 (0)