From 9d60a0f666057c7d59006e0d92be34c55aed8489 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 7 Oct 2021 15:36:25 -0400 Subject: [PATCH] Focus "Name" in PatchStore Dialog when opened (#5227) You have to do this on the event *after* the name editor is showing so in the parent heirarchy changed callbacks. --- src/surge-xt/gui/overlays/PatchStoreDialog.cpp | 7 ++++++- src/surge-xt/gui/overlays/PatchStoreDialog.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/surge-xt/gui/overlays/PatchStoreDialog.cpp b/src/surge-xt/gui/overlays/PatchStoreDialog.cpp index bbbf63add95..0bdc2c477ef 100644 --- a/src/surge-xt/gui/overlays/PatchStoreDialog.cpp +++ b/src/surge-xt/gui/overlays/PatchStoreDialog.cpp @@ -90,7 +90,6 @@ PatchStoreDialog::PatchStoreDialog() auto ed = std::make_unique(n); ed->setJustification(juce::Justification::centredLeft); ed->setWantsKeyboardFocus(true); - ed->grabKeyboardFocus(); addAndMakeVisible(*ed); return std::move(ed); @@ -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) { diff --git a/src/surge-xt/gui/overlays/PatchStoreDialog.h b/src/surge-xt/gui/overlays/PatchStoreDialog.h index 745c22fc298..aba9d3c9b88 100644 --- a/src/surge-xt/gui/overlays/PatchStoreDialog.h +++ b/src/surge-xt/gui/overlays/PatchStoreDialog.h @@ -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);