AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

commit 203ab5eed9f5e37a57cd8cdde50f636eaa667543
parent 281ee7edcb72d52b9c67b1bdec9745e3bec899a4
Author: Jatin Chowdhury <[email protected]>
Date:   Sun, 12 Jun 2022 23:21:58 +0200

Slider regains focus after type-in editing is complete

Diffstat:
MPlugin/Source/GUI/MyLNF.cpp | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 55 insertions(+), 4 deletions(-)

diff --git a/Plugin/Source/GUI/MyLNF.cpp b/Plugin/Source/GUI/MyLNF.cpp @@ -270,15 +270,66 @@ Slider::SliderLayout MyLNF::getSliderLayout (Slider& slider) Label* MyLNF::createSliderTextBox (Slider& slider) { - auto l = LookAndFeel_V4::createSliderTextBox (slider); + struct ReturnFocusSliderLabel : public juce::Label + { + public: + explicit ReturnFocusSliderLabel (Slider& baseSlider) : juce::Label ({}, {}), + slider (baseSlider) + {} + + ~ReturnFocusSliderLabel() override = default; + + void textEditorReturnKeyPressed (TextEditor& editor) override + { + juce::Label::textEditorReturnKeyPressed (editor); + slider.grabKeyboardFocus(); + } + + void textEditorEscapeKeyPressed (TextEditor& editor) override + { + juce::Label::textEditorEscapeKeyPressed (editor); + slider.grabKeyboardFocus(); + } + +// void textEditorFocusLost (TextEditor&) override +// { +// slider.grabKeyboardFocus(); +// } + + std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override + { + return createIgnoredAccessibilityHandler (*this); + } + + Slider& slider; + }; + + auto* label = new ReturnFocusSliderLabel (slider); + + label->setJustificationType (Justification::centred); + label->setKeyboardType (TextInputTarget::decimalKeyboard); + + label->setColour (Label::textColourId, slider.findColour (Slider::textBoxTextColourId)); + label->setColour (Label::backgroundColourId, + (slider.getSliderStyle() == Slider::LinearBar || slider.getSliderStyle() == Slider::LinearBarVertical) + ? Colours::transparentBlack + : slider.findColour (Slider::textBoxBackgroundColourId)); + label->setColour (Label::outlineColourId, slider.findColour (Slider::textBoxOutlineColourId)); + label->setColour (TextEditor::textColourId, slider.findColour (Slider::textBoxTextColourId)); + label->setColour (TextEditor::backgroundColourId, + slider.findColour (Slider::textBoxBackgroundColourId) + .withAlpha ((slider.getSliderStyle() == Slider::LinearBar || slider.getSliderStyle() == Slider::LinearBarVertical) + ? 0.7f : 1.0f)); + label->setColour (TextEditor::outlineColourId, slider.findColour (Slider::textBoxOutlineColourId)); + label->setColour (TextEditor::highlightColourId, slider.findColour (Slider::textBoxHighlightColourId)); auto style = slider.getSliderStyle(); if (style == Slider::LinearHorizontal) - l->setJustificationType (Justification::left); + label->setJustificationType (Justification::left); - l->setFont ((float) slider.getTextBoxHeight()); + label->setFont ((float) slider.getTextBoxHeight()); - return l; + return label; } Component* MyLNF::getParentComponentForMenuOptions (const PopupMenu::Options& options)