From 9bf6148e00b70c15380c47491456e554c34d1e72 Mon Sep 17 00:00:00 2001 From: kobewi Date: Wed, 2 Oct 2024 15:47:36 +0200 Subject: [PATCH] Handle scroll events in RichtTextLabel --- scene/gui/rich_text_label.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index e302927692d..26141663c1c 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2067,16 +2067,27 @@ void RichTextLabel::gui_input(const Ref &p_event) { } } + bool scroll_value_modified = false; + double prev_scroll = vscroll->get_value(); + if (b->get_button_index() == MouseButton::WHEEL_UP) { if (scroll_active) { vscroll->scroll(-vscroll->get_page() * b->get_factor() * 0.5 / 8); + scroll_value_modified = true; } } if (b->get_button_index() == MouseButton::WHEEL_DOWN) { if (scroll_active) { vscroll->scroll(vscroll->get_page() * b->get_factor() * 0.5 / 8); + scroll_value_modified = true; } } + + if (scroll_value_modified && vscroll->get_value() != prev_scroll) { + accept_event(); + return; + } + if (b->get_button_index() == MouseButton::RIGHT && context_menu_enabled) { _update_context_menu(); menu->set_position(get_screen_position() + b->get_position());