Any way to lock text baseline of Label/TextEditor?



I’ve tried lots of combinations of fonts, justifications, borders, label sizes, etc., but the text always jumps around vertically when a label switches into/outof editor mode (with font set the same in both modes). Does any method exist to lock the text baseline between the two modes?

Thanks for any guidance.


A normal label doesn’t jump around, so I guess you’ve used some kind of custom sizes or fonts? There’s no way to “lock” it, I’m afraid, other than getting the L+F of the label and textbox to match.


Thanks for the quick response.

The below snippet makes the text jump vertically when I enter/leave edit mode (with no custom L&F):

progNameLabel = new Label();
progNameLabel->setText("hello", true);
progNameLabel->setEditable(false, true, true);
progNameLabel->setColour(Label::backgroundColourId, Colour(237,237,237));

The amount changes with different setBounds() heights (in my code I haven’t been able to find a magic height to cause 0 shift). Is there a way to avoid (an arbitrary) setBounds()? Can you send me a quick usage that doesn’t jump, so I can use it as a frame of reference? I didn’t see anything applicable in the demo.



I’d still be interested in the de facto way/code to have no vert jumping, but for now I have a kludge of font/size/justifications/L&F/etc. which give a fairly convincing result. Thanks.