FR: "ValueEditor" class which behaves like Slider textbox

I’ve found myself on a couple of occasions re-implementing the behavior that the textbox attached to sliders implements; e.g. accepting only numbers, dismissing virtual keyboard when tapped outside, etc. For this reason I thought it might make sense to refactor it out of the slider and into an individual class?

I saw in the code that it is called “valueBox,” hence the proposal “ValueEditor” for the class name.

JUCE might already have something like this that I’m just missing, but wanted to throw this out there to see if anyone had any thoughts?

I’m actually using a Slider for that and it is relatively easy. Selecting the slider Layout IncDecButtons already get you pretty close. You can remove them by overwriting LookAndFeel like this:

Slider::SliderLayout LookAndFeel_RemoveSliderButtons::getSliderLayout(Slider& slider)
{
  Slider::SliderLayout layout;
  layout.textBoxBounds  = slider.getLocalBounds();
  layout.sliderBounds   = TPixelRect();
  return layout;
}
2 Likes

Ah, that’s really nice to know, will definitely keep this in mind going forward! Somehow missed the IncDecButtons layout. If it’s that straightforward then my feature request is probably not necessary. Thank you!