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

RichTextLabel does not perform well 'out of the box' #10924

Closed
Tracked by #39144
Brickcaster opened this issue Sep 3, 2017 · 8 comments
Closed
Tracked by #39144

RichTextLabel does not perform well 'out of the box' #10924

Brickcaster opened this issue Sep 3, 2017 · 8 comments

Comments

@Brickcaster
Copy link
Contributor

Brickcaster commented Sep 3, 2017

Operating system or device, Godot version, GPU Model and driver (if graphics related):
Godot 2.1.4

Issue description:
The behavior of RichTextLabel is unsatisfactory. One cannot simply do:

var node = RichTextLabel.new()  
node.set_bbcode("Some Text")  
add_child(node)

And have it work.

Instead, one must do:

var node = RichTextLabel.new()  
init_richtextlabel(node)  
node.set_bbcode("Some Text")  
add_child(node)  
...  
func init_richtextlabel(node):  
	node.set_use_bbcode(true) #Not strictly necessary, but otherwise we would use Label. 
	node.set_scroll_active(false) #Not strictly necessary, but this behavior is distinctly different from Label.  
	node.set_custom_minimum_size(Vector2(50, 16)) #This or the next two lines, depending on desired behavior  
	#node.set_h_size_flags(SIZE_EXPAND_FILL)  
	#node.set_v_size_flags(SIZE_EXPAND_FILL)  

A side note is that node.set_v_size_flags(SIZE_EXPAND) does not work as expected to make the node size match the text size and using SIZE_EXPAND_FILL can be undesirable.

Expected Behavior:
RichTextLabel nodes behave more comparable to Label nodes, automatically sizing them to match their contents and use_bbcode flag by default is set to true.

@toger5
Copy link
Contributor

toger5 commented Sep 3, 2017

So basically you want the default values to be changed?

I thubk that makes sense

@Brickcaster
Copy link
Contributor Author

Not just the default values, but also the set_v_size_flags(SIZE_EXPAND) behavior does not seem to match the behavior of Label nodes.

@Paluth
Copy link

Paluth commented Sep 3, 2017

Just to note. I'm new to godot. I tried using richtextlabel and it didn't work as expected. I didn't know I had to set options for it to work. I ended up giving up on using it.
I also feel it should work out of the box, without setting any options or it makes learning godot harder than it should.
That being said, I know changing the behavior of richtextlabel can cause problem for people already using it. But for 3.0 there is no such concern as it already breaks compatibility in several places. So this is an opportunity to fixes it.

To sum up, I think the richtextlabel should work exactly like the regular label, except that it should take in bbcode instead of regular text.

@Brickcaster
Copy link
Contributor Author

I got 3.0 to compile and I verified that this also occurs in 3.0

@akien-mga
Copy link
Member

Is this still reproducible in Godot 3.0 RC1?

@mjtorn
Copy link
Contributor

mjtorn commented Apr 9, 2018

As a Godot n00b who's involved in the Escoria framework, I can confirm having an automatically scaled RichTextLabel is infuriatingly painful as opposed to just using a Label.

For historical reasons, I assume, the node is a child of a Container that's a child of another Container with SIZE_EXPAND set. Neither that nor SIZE_EXPAND_FILL work as well as they'd work with a simple Label. So I don't think the containers are at fault here, as also attested by the previous comments.

Unfortunately the framework assumes that it's a RichTextLabel although I tested hacking around the code to enable the use of a Label for testing, so this really should be better, by eg. behaving like a Label.

Is there a technical reason why this isn't so?

Version 3.0.2.

@Calinou
Copy link
Member

Calinou commented Jun 14, 2020

use_bbcode is most likely false by default for "security" reasons. There are many cases where you want to use RichTextLabel for styling but want to prevent players from adding their own formatting (or worse, clickable links that could lead to phishing sites or similar).

We could set it to true by default in 4.0, but that comes with its implications as I said above.

@akien-mga
Copy link
Member

This should likely be rewritten as a proposal on https://github.com/godotengine/godot-proposals to assess what potential changes should be made to default values, and what the community at large thinks about it.

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

7 participants