The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

Something like the effect of RichTextLabel's bool scroll_active = false, but with still working scrolling?

in Engine by (722 points)

Have you looked into the scroll_to_line() function? Maybe you can set up a custom function to use scroll_to_line() when the text needs to be moved?

I know about scrolltoline, but it kind of "cripples" the way the RichTextLabel works.
I would want to be able normally scroll the content of RichTextLabel, but not to see the handle of the RichTextLabel.

1 Answer

+2 votes
Best answer

You can set the alpha value (hiding it didn't work for me)

func _ready():
    $RichTextLabel.get_child(0).modulate.a = 0

Edit:

To make this answer more clearer.

Some nodes, like the RichTextLabel already consist of several nodes.
You can see this when running your project and switching the scene tree from local to remote.

So the VScrollBar is the first child of the RichTextLabel node, and you can make it invisible by setting its scale or alpha value to 0.

by (1,476 points)
selected by

It's worth pointing out here that making something invisible is not the same as hiding it though! You can still click in the area where the scrollbar is located and move the handle. Because of this, I would recommend changing rect_scale instead:

$RichTextLabel.get_child(0).rect_scale.x = 0

This way the scroll bar isn't occupying any space, thus cannot be clicked and dragged around as well. However, scrolling with the mouse wheel still works fine.

Thank you @Adam_S and @njamster for taking time to answer my question.
Modulate just sets alpha to 0, let's say that it "hides" the whole RichTextLabel. In the result the text is not visible as well.
What I meant (sorry for not explaining it better in the question) was to hide the handle of the scroll but leaving the text visible.

What I meant was to hide the handle of the scroll but leaving the text visible

And what we proposed does precisely that! Hiding the text would be:

$RichTextLabel.rect_scale.x = 0

but here we are working on the first child of the RichTextLabel instead:

$RichTextLabel.get_child(0).rect_scale.x = 0

And this first child should always be the VScrollBar - check the remote tree!

I am doing something wrong I guess, but after issuing

$Control/RichTextLabelget_child(0).scale.x = 0 

I get
Invalid get index 'scale' (on base: 'VScrollBar') in debugger.

Probably set_scale(Vector2(0, y) would work but it is not what I am looking for.
I would like to have a normal, unscaled text, that user could normally scroll without seeing the scroll handle.
Adding VScrollBar as child does nothing, as The RichTextLabel still has a visible scroll handle.
I guess there would be possible to turn the scroll of in RichTexTLabel and set VScrollBar signals and write a function that would "move" RichTextLabel according to the signals of VScrollBar, but I was looking for a rather simple solution within the RichTextLabel itself.

My bad, sorry! It's rect_scale, not scale. I'll edit my answers accordingly.

I would like to have a normal, unscaled text, that user could normally scroll without seeing the scroll handle.

And you will get precisely get that. :) This time for real, hehe.

Please take look at my edited answer.

Thanks njamster, I appreciate your efforts, but I don't get it. :(
I am probably to stupid, but like I mentioned above, no matter what I do with child-VScrollBar, the parent-RichTextLabel's scroll handle is still visible.
I don't see any simple solution without involving signals and code checking the scroll value in every frame or something. :(
If there is a solution, I guess I would need a step by step instruction with drawings :)

Would you be willing to create a simple project example showing what you mean?
I guess with just a simple structure like:

Control
   I
    - RichTextLabel
              I
               - VScrollBar

to show me how you make RichTextLabel scroll hande not visible and text scrolling still working?

All right! Thank you for updating the answer. Now I get it! Checking the Remote instead looking at Local. Stupid me. I had no idea what you ment by that in the first place. Now I understand. Many thanks, really! :D

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.