I can make a Label's text centered, however there is no way to make its edit box's text centered, is there?
No, sorry - never got around to adding justification to TextEditors.. It's been requested before, I should do it at some point..
Thanks, that's what I was thinking. A first implementation would be that the editor automagically follows the label's alignment (sounds logic).
i've too have come upon a situation where this would be really nice..
although i'd like right justification
I’d really like to see support for Justification added to TextEditor, in particular so that a Label’s TextEditor can match the alignment of the Label itself.
There are lots of threads requesting this… pretty please…
I’m newer to JUCE, but I really would appreciate this feature. Any word on this?
While this would be a really useful feature, you can work around it reasonably well in simple cases and where there is only a single line.
Create your own custom
Label subclass and override
Label::createEditorComponent() where you can create your own subclass of
TextEditor. This text editor needs to be a
TextEditor::Listener and listen to itself in both cases.
In the listener callbacks
ComponentListener::componentMovedOrResized you can measure the text using
TextEditor::getTextHeight(). Then you can resize the TextEditor so that it is just big enough to hold the line of text and position it wherever you like within the parent.
Thanks @martinrobinson, got it working with your advice.
For my own and other’s future reference (and easy copy and paste), here are the Label and TextEditor subclasses:
I added the
KeyListener callback so that it keeps the editor entered while the user types.
This seems to be one small change to JUCE, but a much anticipated one. Can we pretty-please have this in a future JUCE version?