diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index bacc85e33b1..fa569e3603c 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -330,6 +330,7 @@ The restricted number of characters to display in the label. If [code]-1[/code], all characters will be displayed. + [b]Note:[/b] Setting this property updates [member percent_visible] based on current [method get_total_character_count]. diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 404d656683d..7cde6bbdc50 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2688,6 +2688,7 @@ void RichTextLabel::set_percent_visible(float p_percent) { visible_characters = get_total_character_count() * p_percent; percent_visible = p_percent; } + _change_notify("visible_characters"); update(); } @@ -2870,6 +2871,15 @@ void RichTextLabel::_bind_methods() { void RichTextLabel::set_visible_characters(int p_visible) { visible_characters = p_visible; + if (p_visible == -1) { + percent_visible = 1; + } else { + int total_char_count = get_total_character_count(); + if (total_char_count > 0) { + percent_visible = (float)p_visible / (float)total_char_count; + } + } + _change_notify("percent_visible"); update(); }