Label editable partly

#1

Hello,
I wonder is there any easy way to make JUCE::Label editable partly? Or do I need to write my own method or class?

I mean something like that, my label text is for example “x / 10”, and I want to be able to edit only “x”.

0 Likes

#2

I think you would have to make your own custom implementation for this, I’m not sure of any JUCE features that allow for this…

I believe one way you could do it is to have some sort of “post-fix” text that is always added to the “editable” text.

Then whenever the label shows its editor - Label::editorShown() - you can set the editor’s text to just the editable part (“x”), and when it’s hiding - Label::editorAboutToBeHidden() - you can add the post-fix text (" / 10") to what the user typed in (the new text for “x”).

At least that’s one way I’ve handled this kind of thing before :slight_smile: if you want it to be where just the text editor appears over the “x” then you could achieve it by using two labels and some positioning…

0 Likes