Any way to lock text baseline of Label/TextEditor?


#1

Hi,

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.


#2

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.


#3

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->setBounds(323,519,258,38);
progNameLabel->setEditable(false, true, true);
progNameLabel->setColour(Label::backgroundColourId, Colour(237,237,237));
addAndMakeVisible(progNameLabel);

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.

Thanks.


#4

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.