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

Text in RichTextLabel disappears when you click bbcode enable in inspector #75899

Closed
Daniel-da-Silva opened this issue Apr 10, 2023 · 8 comments

Comments

@Daniel-da-Silva
Copy link

Godot version

3.5.2

System information

Happened on Linux and Windows PC

Issue description

When you create a RichTextLabel, write text into the inspector, enable the bbcode, the text box in the inspector disappears. If you disable bbcode again, the text is away. If you did this in 3.5.1 the text box in the inspector did not disappear and you could make changes.

This seems to be a regression, since the problem does not appear on 3.5.1.

Steps to reproduce

Create RichTextLabel. Open Inspector. Write in the Text field, not the bbcode field, go to the bbcode field, enable it. Text box in inspector disappears and the contents too. Disable it again, text box in inspector is back, text still missing.

Minimal reproduction project

It's faster to make a new one, and follow the steps.

@KoBeWi
Copy link
Member

KoBeWi commented May 22, 2023

This is intended behavior. When BBCode is enabled, you are supposed to edit the bbcode_text property.

@KoBeWi KoBeWi closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2023
@Daniel-da-Silva
Copy link
Author

Hey @KoBeWi I think you misread the problem. The problem is that text gets lost. Not that you need to edit it in the bbcode_text property. If one writes stuff into the text box, enables the bbcode, thex textbox disappears, if the person who wrote stuff there disables the bbcode box again the text is still not there. In my case I used the textbox for all additional credits which would have been annoying to rewrite. (Furthermore the data is still there because if it was intended to be deleted which would be weird it shouldn't be possible to reaccess it through an older Godot version.)

Please reopen.

@KoBeWi
Copy link
Member

KoBeWi commented May 23, 2023

Not sure why do you say it's a regression if it was always like that. Once you modify the bbcode_text property, the text contents get overwritten and disappear forever. This behavior is confusing, hence the text field is hidden once you enable BBCode.

The issue is fixed properly in Godot 4. There is only 1 text property. The fix can't be backported.

@Daniel-da-Silva
Copy link
Author

Just to make sure I opened a new project, wrote text in the text field, enabled bbcode and wrote text there and the old text is still visible as long as I don't click on something else on the inspector and back on it. This is not the case on 3.5.2. But you are right in the case if you "reload" it, click on something else and back on it (I didn't know this).

Either way I think that the text gets lost is still a bug - and how it is in Godot 3.5.2 doesn't even give you the option to reselect the text if you didn't reload it. I almost lost 20-30 minutes of work because of this hiding when I ported the game from Godot 3.5.1 to 3.5.2 if I hadn't gotten back to Godot 3.5.1 because just clicking on enable and clicking on disable right away doesn't produce the problem I had in Godot 3.5.1 but in Godot 3.5.2, that's why I called it a regression but after you explained it, I now would call it something else.

That's sad that it can't be backported but isn't there a way to find a workaround? Let the text field stay even if it isn't shown?

@KoBeWi
Copy link
Member

KoBeWi commented May 23, 2023

Ok I investigated the issue a bit more and it's... interesting 🤔
Firstly, get_text(), i.e. the getter for text property is implemented like this:

String RichTextLabel::get_text() {
String text = "";
Item *it = main;
while (it) {
if (it->type == ITEM_TEXT) {
ItemText *t = static_cast<ItemText *>(it);
text += t->text;
} else if (it->type == ITEM_NEWLINE) {
text += "\n";
} else if (it->type == ITEM_INDENT) {
text += "\t";
}
it = _get_next_item(it, true);
}
return text;
}

The text isn't stored internally as String, instead the method seems to re-parse everything. The result is dependent on whether the BBCode is enabled or not. Once you toggle BBCode, the text is already gone. In 3.5.1, nothing happens. The text field stays in the inspector and just holds invalid, outdated data. In 3.5.2 the toggle triggers inspector refresh, which fetches the new value and updates the text field with new value.

The only way to restore the old text is either reload the scene or, especially if it didn't help, copy it manually from the tscn file. Not sure if there is a better way to handle it, without involving any hacks.

I can reopen the issue, since it's a somewhat valid concern, but it might stay unresolved.

@Daniel-da-Silva
Copy link
Author

Thank you @KoBeWi 👍

@akien-mga akien-mga modified the milestones: 3.x, 3.6 Jun 7, 2023
@akien-mga
Copy link
Member

Fixed by #77403.

@Daniel-da-Silva
Copy link
Author

Thanks! :)

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

4 participants