# TextEditor Justification

**URL:** <https://forum.juce.com/t/texteditor-justification/6937>\
**Category:** General JUCE discussion\
**Created:** [May 29, 2011, 10:46pm UTC](https://forum.juce.com/t/texteditor-justification/6937 "2011-05-29T22:46:07Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![SonicZentropy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/soniczentropy/32/665_2.png) [@SonicZentropy](https://forum.juce.com/u/SonicZentropy)\
**Post date:** [May 11, 2016, 11:16am UTC](https://forum.juce.com/t/texteditor-justification/6937/21 "2016-05-11T11:16:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 11, 2016, 2:34pm UTC](https://forum.juce.com/t/texteditor-justification/6937/22 "2016-05-11T14:34:25Z")

</div>

Damn… must get around to this one day!

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [May 11, 2016, 2:58pm UTC](https://forum.juce.com/t/texteditor-justification/6937/23 "2016-05-11T14:58:05Z")

</div>

> [@SonicZentropy](#):
>
> 5 Year thread anniversary bump!

…it’s a 19 days lag left (may 30th, 2011) - that’s a challange 😉

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [May 11, 2016, 4:29pm UTC](https://forum.juce.com/t/texteditor-justification/6937/24 "2016-05-11T16:29:46Z")

</div>

Just set it as an interview question next time you’re hiring at roli … someone will come up with a good fix 😉

---

<div class="post-metadata">

**Author:** ![SonicZentropy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/soniczentropy/32/665_2.png) [@SonicZentropy](https://forum.juce.com/u/SonicZentropy)\
**Post date:** [May 12, 2016, 12:12am UTC](https://forum.juce.com/t/texteditor-justification/6937/25 "2016-05-12T00:12:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2016, 12:01pm UTC](https://forum.juce.com/t/texteditor-justification/6937/26 "2016-05-12T12:01:59Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![tadnicol](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tadnicol/32/5141_2.png) [@tadnicol](https://forum.juce.com/u/tadnicol)\
**Post date:** [June 6, 2017, 4:15am UTC](https://forum.juce.com/t/texteditor-justification/6937/27 "2017-06-06T04:15:31Z")

</div>

+1 😉

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [June 6, 2017, 6:10am UTC](https://forum.juce.com/t/texteditor-justification/6937/28 "2017-06-06T06:10:18Z")

</div>

For single lines and single style runs, there is a workaround here: [Editable label's TextEdit centered text](https://forum.juce.com/t/editable-labels-textedit-centered-text/11994/10)

---

<div class="post-metadata">

**Author:** ![adam-eqip](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@adam-eqip](https://forum.juce.com/u/adam-eqip)\
**Post date:** [August 8, 2017, 3:58pm UTC](https://forum.juce.com/t/texteditor-justification/6937/29 "2017-08-08T15:58:24Z")

</div>

I guess it’s my turn! +1

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [September 20, 2017, 7:52pm UTC](https://forum.juce.com/t/texteditor-justification/6937/30 "2017-09-20T19:52:18Z")

</div>

It’s my turn now to `+1`!

---

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [September 21, 2017, 8:04am UTC](https://forum.juce.com/t/texteditor-justification/6937/31 "2017-09-21T08:04:20Z")

</div>

I dream of a JUCE newsletter stating among its cover features: “customizable TextEditor Justification” 😆

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [September 21, 2017, 8:59pm UTC](https://forum.juce.com/t/texteditor-justification/6937/32 "2017-09-21T20:59:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 22, 2017, 1:49pm UTC](https://forum.juce.com/t/texteditor-justification/6937/33 "2017-09-22T13:49:18Z")

</div>

Happy Friday!

> <https://github.com/juce-framework/JUCE/commit/d00a459480063b1537be80c32cb70f296538cb99>

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [September 22, 2017, 2:24pm UTC](https://forum.juce.com/t/texteditor-justification/6937/34 "2017-09-22T14:24:14Z")

</div>

![](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/c/cd026a9159f4907ad65d2896f351318636531931.gif)

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [September 22, 2017, 4:39pm UTC](https://forum.juce.com/t/texteditor-justification/6937/35 "2017-09-22T16:39:56Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/9/9ec22672d08cd553222194b2ccb3b547440373af.jpg)

---

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [September 24, 2017, 9:49am UTC](https://forum.juce.com/t/texteditor-justification/6937/36 "2017-09-24T09:49:47Z")

</div>

(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?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 24, 2017, 1:36pm UTC](https://forum.juce.com/t/texteditor-justification/6937/37 "2017-09-24T13:36:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [September 24, 2017, 5:24pm UTC](https://forum.juce.com/t/texteditor-justification/6937/38 "2017-09-24T17:24:36Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![roeland-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/roeland-2/32/738_2.png) [@roeland-2](https://forum.juce.com/u/roeland-2)\
**Post date:** [September 25, 2017, 1:24am UTC](https://forum.juce.com/t/texteditor-justification/6937/39 "2017-09-25T01:24:36Z")

</div>

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));
```

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [November 28, 2017, 3:49pm UTC](https://forum.juce.com/t/texteditor-justification/6937/40 "2017-11-28T15:49:34Z")

</div>

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

[Previous page](https://forum.juce.com/t/texteditor-justification/6937.md?page=1)

[Next page](https://forum.juce.com/t/texteditor-justification/6937.md?page=3)
