From 95feb6bb828302bc25eebf5656fe1a94659c6826 Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 23 May 2023 19:04:39 +0200 Subject: [PATCH] Cache text property when toggling BBCode --- scene/gui/rich_text_label.cpp | 9 +++++++++ scene/gui/rich_text_label.h | 1 + 2 files changed, 10 insertions(+) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 874c3e0ecb8..0e57d4e759d 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2741,8 +2741,17 @@ void RichTextLabel::set_use_bbcode(bool p_enable) { if (use_bbcode == p_enable) { return; } + + if (p_enable) { + cached_text = get_text(); + } + use_bbcode = p_enable; set_bbcode(bbcode); + + if (!p_enable) { + set_text(cached_text); + } property_list_changed_notify(); } diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index fb49e24e5cf..fbd213c4668 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -408,6 +408,7 @@ private: bool use_bbcode; String bbcode; + String cached_text; int fixed_width;