Search code examples
objective-ccocoanstextfield

NSTextField: do not strip trailing spaces while center-aligned


My crusade against static text NSTextField goes on.

The question for today is: Why do center-aligned NSTextField-s even dare to strip trailing spaces from the lines they are given? Why don`t they strip leading spaces then?

But, most importantly, how do I stop them from butchering my text?

P.S.: if you`re wondering why I want that, refer to this question of mine.

P.S.#2: seems like a similar question has been asked before — to no avail, though.


Solution

  • Based on a quick experiment: Select the label field and in the attributes pane change the Layout from Truncates to Scrolls the text should now centre taking into account the trailing spaces.

    Or you can start with an editable text field and turn off the border, draws background and editable behavior settings.

    HTH