TextEditor Justification

5 Year thread anniversary bump! Currently abusing setBorder to fake actual justification as a hacky workaround and I die a little inside every time I see that chunk of code

2 Likes

Damnā€¦ must get around to this one day!

2 Likes

ā€¦itā€™s a 19 days lag left (may 30th, 2011) - thatā€™s a challange :wink:

Just set it as an interview question next time youā€™re hiring at roli ā€¦ someone will come up with a good fix :wink:

1 Like

Ha! I like this. Jules, if I rewrite TextEditor and fix it, will you guys hire me? :smile:

Well, if you send us an improved version of TextEditor that demonstrates an absolutely beautiful coding style and stunning abilities, then yes, absolutely weā€™ll hire you!

2 Likes

+1 :wink:

1 Like

For single lines and single style runs, there is a workaround here: Editable label's TextEdit centered text

2 Likes

I guess itā€™s my turn! +1

Itā€™s my turn now to +1!

I dream of a JUCE newsletter stating among its cover features: ā€œcustomizable TextEditor Justificationā€ :laughing:

Heh. Iā€™d love to see a poll of hot-topic feature requests. This oneā€™s been around for ~6 years - always curious to see what else is frequently asked for in a simple list.

Happy Friday!

16 Likes

3 Likes

image

(and yet another requestā€¦ :- )

Only the horizontal alignment is taken into account at the moment (i.e, topRight/centredRight/bottomRight all lead to the same result).
Is there any plan to also support the vertical alignment?

Well, it scrolls vertically so not really sure what youā€™d expect to happen if you asked for a different vertical alignment.

humā€¦ right. I was in a case where the text is much shorter than the text editorā€™s height and without scrollbars, so I did not think about it.
Perhaps that should be taken into account until the scrollbars appears?
Let see if anyone else needs it.
(personally I donā€™t need it anymore actually at the moment - I just had a small vertical alignement issue but that was due to something else).

I think it makes sense in the common case when an editor is single-line and all text has the same font. These look really weird if the text is not vertically centred. Right now you have to do something like this whenever you create a single line text editor:

float extra = editor.getHeight() - editor.getFont().getHeight() - editor.getBorder().getTopAndBottom();
editor.setIndents(4, (int) (extra * 0.5f));
2 Likes

I hacked up the TextEditor to be single line only and support vertical justification: https://github.com/FigBug/SingleLineTextEditor

3 Likes