R – Setting textAlign to centered on a textArea, trailing spaces aren’t used to determine centering


Maybe I'm doing something wrong but I have a textarea where I've specified textAlign = center and if I type in text with several trailing spaces, it doesn't count the spaces towards centering the text. If I add another character to the text (after all the spaces) it then all of a sudden centers the line, is this a bug, can anybody think of a good solution?

To replicate:
-Create a textArea
-Set textAlign=center
-Run the application and type in something like 'FOOBAR' followed by 10 spaces, note that it centers FOOBAR but stops centering the text while you're typing the spaces
-Now type another string like 'WTF', now it'll all of a sudden center the whole line.

Best Solution

This is the default behavior in Flash. Even the low level flash.text.TextField, with alignment set to center, behaves like this. I think it makes sense too, as including white space in aligning may not be desirable in most situations. It would lead to the impression that the text is not aligned properly (as it would appear moved towards the left side of the text area).

Related Question