-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Fixing Button text ignores breakline (\n) #2967 #24374
Conversation
When we add a \ n or \ t directly in the editor or add \ t to GDScript, those characters are either printed or discarded and have no effect. This happen is because if the string contains '\ n', Variant object stores two printable characters '\' and 'n'. So just check the string and change the characters '\' 'n' and '\' 't' to '\ n' and '' (4 spaces). For this was added a method to the String class, check_control_characters, which does this verification. And this method is called in the Control::get_tooltip. Fixing #2967 Button text ignores breakline (\n)
When we add a \ n or \ t directly in the editor or add \ t to GDScript, those characters are either printed or discarded and have no effect. To fix this it was enough to call the check_control_characters method of the class String in the methods Label::set_text and Label::get_text. Fixing #2967 Button text ignores breakline (\n)
When we add a \ t directly in the editor or in the GDScript, those characters are either printed or discarded and have no effect. To fix this it was enough to call the check_control_characters method of the class String in the methods Button::set_text and Button::get_text. Fixing #2967 Button text ignores breakline (\n)
Clearing commented and unneeded code lines
@cesarpinho Please fix the conflicts. |
String str_begin = s.substr(0, tab_pos); | ||
String str_end = s.substr(tab_pos + 1, s.length()); | ||
|
||
s = str_begin + " " + str_end; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we always assume, that \t == 4 spaces? Shouldn't it be configurable per usecase?
@cesarpinho Requesting rebase. |
@cesarpinho The merges you pushed aren't the same as a rebase. Godot requires contributors to make their PRs have good Git history in order to be accepted. Please see this article for more information: https://docs.godotengine.org/en/latest/community/contributing/pr_workflow.html |
@cesarpinho Requesting rebase and squash. |
This PR has not been in a good state for about a year, closing. |
After a long review of the code, the discussion on the issue #2967 page and the other merged issues (#4327 and #21334), I present a solution proposal.
In this comment, @StraToN say :
And that's what I did. I fix the tabs in the Buttons' captions, Labels text and Control tooltips and fix the line breaks in the Label text and Control tooltip.
Before
After
Fix #2967