RichTextLabel with Button after Text

dancingdavejonesdancingdavejones Posts: 5Member

Hello all,
I have a questionnaire type project with a few RichTextLabel's that contain long text instructions and have buttons attached to the bottom of the Labels like so:
For most of these labels the layout is fine as the buttons are far under the text but on a few whose text fills up the entire label to the point where the buttons overlap the text. This not only looks horrible but the choices the buttons present shouldn't be seen until all the text has been read.
How can I set up these components so that the buttons only show on screen after the last bit of text regardless of how long/far you have to scroll through.

Tags :


  • ltngamesltngames Posts: 1Member

    Using some of the values given to us by the scrollbar class, you should be able to show your buttons after the scrollbar's value has reached the max value. From what I was able to figure out, the true max_value is the max_value minus the page value. To save on resources I used the scrollbar's value_changed signal instead of the _process function.

    extends Node2D
    onready var scrollbar = $RichTextLabel.get_v_scroll()
    func _ready():
        scrollbar.connect("value_changed", self, "on_scrollbar_value_changed")
    func on_scrollbar_value_changed():
        # From what I gather, the true max value is the max-value minus the
        # page value.
        var scrollbar_total_value = scrollbar.max_value -
        if scrollbar.value == scrollbar_total_value:
            # Show your buttons here
            $Button.visible = true
            $Button2.visible = true

    I hope this helps you out in some way, cheers!

  • MegalomaniakMegalomaniak Posts: 2,771Admin

    Don't parent the buttons to the RichTextLabel but to the Control above. For the visibility, see @ltngames post above.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file