Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Textfield autoSize bug with isHtmlText enabled #924

Open
jimmymjing opened this issue Nov 10, 2016 · 6 comments
Open

Textfield autoSize bug with isHtmlText enabled #924

jimmymjing opened this issue Nov 10, 2016 · 6 comments

Comments

@jimmymjing
Copy link

Hello,
Textfield's autoSize doesn't work once I upgraded to Starling 2.0.

textFieldIns.isHtmlText = true;
textFieldIns.autoSize = TextFieldAutoSize.BOTH_DIRECTIONS;

This bug has been mentioned here also:
#820

I find that if I disable isHtmlText property the autoSize would work properly though.

@PrimaryFeather
Copy link
Contributor

Unfortunately, that's a limitation of the autoSize property: Horizontal autoSize does not work for HTML text, since such text might contain custom alignment.

For example, think of HTML content that contains one line that's aligned to the left, and another that's aligned to the right. What would be the optimal size for such a TextField?

I definitely need to add this information to the API reference. I'll do that!

@jimmymjing
Copy link
Author

But autoSize works with HTML text in Starling 1.7...
The way I found this problem is because I updated the Starling to 2.0.

@PrimaryFeather
Copy link
Contributor

Hm, well, Starling 1.7 allowed to use autoSize on html text, but if you inserted text with a problematic alignment (e.g. both left- and right-aligned paragraphs), this caused an exception. Thus the change in Starling 2.0 to not allow autoSize for HTML text at all, to play safe. Unfortunately, there is no way I can find out myself which kinds of alignments are used inside the text.

Sorry! 😦

@jimmymjing
Copy link
Author

jimmymjing commented Nov 14, 2016

Thanks so much for your reply, Daniel! I will try to find other solutions then.
Actually I was trying to achieve a typewriter effect for subtitles. And I need </br> for line break.
I set the textfield as autsized so I could vertically center the textfield depending on how many lines it may contain.

@PrimaryFeather
Copy link
Contributor

Your welcome!

I set the textfield as autsized so I could vertically center the textfield depending on how many lines it may contain.

Hm — I just checked this, and vertical autosizing should actually work! It's just the horizontal autosize variants that don't. So you could set the TextField to a fixed width, but let the height be automatically calculated.

Could you try that out?

@jimmymjing
Copy link
Author

Hello Daniel,
Yes, vertical autosizing works perfectly! Thanks.
As you've answered on the forum, I will try monospace letter solution for center-aligned typewriter effect.(as it is a very common RPG games subtitle effect. just wonder how they achieved this...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants