Merge pull request #104715 from Andrewyuan34/add-auto-scroll

Add auto-scroll behavior when selecting text outside the visible area in RichTextLabel
This commit is contained in:
Thaddeus Crews 2025-10-03 12:01:05 -05:00
commit 71a485a1af
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
2 changed files with 132 additions and 80 deletions

View file

@ -37,6 +37,10 @@
#include "scene/resources/image_texture.h"
#include "scene/resources/text_paragraph.h"
#ifdef TOOLS_ENABLED
#include "editor/themes/editor_scale.h"
#endif
class CharFXTransform;
class RichTextEffect;
@ -680,6 +684,17 @@ private:
void _scroll_changed(double);
int _find_first_line(int p_from, int p_to, int p_vofs) const;
#ifdef TOOLS_ENABLED
const real_t auto_scroll_speed = EDSCALE * 2.0f;
#else
const real_t auto_scroll_speed = 2.0f;
#endif
Vector2 last_clamped_mouse_pos;
Timer *click_select_held = nullptr;
Vector2 local_mouse_pos;
bool is_selecting_text = false;
void _update_selection();
_FORCE_INLINE_ float _calculate_line_vertical_offset(const Line &line) const;
virtual void gui_input(const Ref<InputEvent> &p_event) override;