Request - Text editor center alignment

Use a juce::Label, call setJustificationType(), call setEditable()?

juce::Label in edit mode uses a TextEditor, foolio!

haha woops!

Up ?

Trying to make a centered editable label whose edit box has also centered text... Has someone achieved that without hacking into Juce?

Nope, cause there's no LookAndFeel method like drawTextEdit.

To make TextEdit (or Label in editmode) centred , we have to override methods such as drawing text, drawing selected text, drawing Caret, etc...

I will try to do it, if there'll no update until end of the year.

Cheers !

Thanks! linked: http://www.juce.com/forum/topic/editable-labels-textedit-centered-text

Here is a workaround, for a vertically centered one-line TextEditor:

TextEditor myTextEdit;
...
int fontHeight = myTextEdit.getFont().getHeight();
int topIndent = ( myTextEdit.getHeight() - fontHeight ) / 2;
int leftIndent = fontHeight / 2;
myTextEdit.setBorder( BorderSize<int>(0, 0, 0, 0) );
myTextEdit.setIndents( leftIndent, topIndent );

 

2 Likes