Skip to content

Commit

Permalink
Focus "Name" in PatchStore Dialog when opened (surge-synthesizer#5227)
Browse files Browse the repository at this point in the history
You have to do this on the event *after* the name editor is showing
so in the parent heirarchy changed callbacks.
  • Loading branch information
baconpaul authored Oct 7, 2021
1 parent 5ced8f7 commit 9d60a0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/surge-xt/gui/overlays/PatchStoreDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ PatchStoreDialog::PatchStoreDialog()
auto ed = std::make_unique<juce::TextEditor>(n);
ed->setJustification(juce::Justification::centredLeft);
ed->setWantsKeyboardFocus(true);
ed->grabKeyboardFocus();

addAndMakeVisible(*ed);
return std::move(ed);
Expand Down Expand Up @@ -178,6 +177,12 @@ void PatchStoreDialog::setSurgeGUIEditor(SurgeGUIEditor *e)
}
}

void PatchStoreDialog::parentHierarchyChanged()
{
if (nameEd->isShowing() && isVisible())
nameEd->grabKeyboardFocus();
}

void PatchStoreDialog::onSkinChanged()
{
auto resetColors = [this](const auto &typein) {
Expand Down
1 change: 1 addition & 0 deletions src/surge-xt/gui/overlays/PatchStoreDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct PatchStoreDialog : public OverlayComponent,
~PatchStoreDialog();
void paint(juce::Graphics &g) override;
void resized() override;
void parentHierarchyChanged() override;

SurgeGUIEditor *editor{nullptr};
void setSurgeGUIEditor(SurgeGUIEditor *e);
Expand Down

0 comments on commit 9d60a0f

Please sign in to comment.