Shouldn't this hide the slider its textbox? For some reason it doesn't hide anymore

since my last git update (4 days ago). Did you change something here, Jules?




Nope, don't think I've touched that.


Okay, thanks


I’m having some trouble with this. Is there a reason why Slider::hideTextBox wouldn’t work? I’m calling in the parent component constructor. Also tried resize and elsewhere in the code.

Stepping through the code, Label::hideEditor does not execute its contents as editor is nullptr.

I’m already subclassing but would rather not have to hack the subclass anymore than I need to…


Solved (I found the answer in my own codebase!)

slider.setTextBoxStyle(Slider::TextEntryBoxPosition::NoTextBox, true, 0, 0);

The API is confusing - hideTextBox should really be called removeTextBoxFocus or something.


I just ran into this, actually - the behavior I was after is a Slider that on double-click shows the text-box editor, and a subsequent value entry, focus loss, or acceptance that hides it. It gets tricky internally, since everything is encapsulated in a pimpl, and isn’t accessible. (by design)

I also needed to remove the textual suffix from the label edit field, since the width of the label editor is clamped to the bounds of the parent component. To make matters worse, the editor and label get destroyed and created dynamically when setTextBoxStyle() is called.

This is nasty, but:

    pblc void mouseDoubleClick(const MouseEvent &event) override 
        // Constructs our textbox.				
        setTextBoxStyle(Slider::TextBoxAbove, false, miEditorWidth, 25);
        // Hack to force editor creation & focus.

        // Grab the parent label from the focused editor.
        mpLabel = dynamic_cast<Label*>(getCurrentlyFocusedComponent()->getParentComponent());
        // Listen for editor open/close events.

        // Strip suffix (This destroys the focused editor)
        mpLabel->setText(String(getValue(), 1), NotificationType::dontSendNotification);

        // Force editor focus again, after the above setText() call.

This allows me to bind listeners to the label after fetching a reference to it once setTextBoxStyle() was called to both create it, and give it keyboard focus. After this, I control visibility via standard setVisible() calls that happen when we receive events from the Label.

Slider is a beast, and I didn’t really have time or interest in hacking on it. There is almost certainly a better way to do this, but it’s what I came up with, in a pinch.




This was helpful, thanks!

For anyone else coming across this, what I did was made my custom Slider class inherit from public Slider and private Label::Listener and in the editorHidden(Label*, Editor&) method, checked to make sure that label == mpLabel then label->setVisible(false) (which is what I assumed you meant by “control visibility via standard setVisible calls”).

Hacky? Probably. Functional? You bet. :slight_smile:

Now I just need to put this code into its own module rather than the PluginEditor.h file…