Add auto-scroll behavior when selecting text outside the visible area in RichTextLabel

This commit is contained in:
AndrewYuan34 2025-03-28 03:21:20 -04:00
parent 42c7f14422
commit 4774b57e4d
2 changed files with 132 additions and 80 deletions

View file

@ -36,6 +36,10 @@
#include "scene/gui/scroll_bar.h"
#include "scene/resources/text_paragraph.h"
#ifdef TOOLS_ENABLED
#include "editor/themes/editor_scale.h"
#endif
class CharFXTransform;
class RichTextEffect;
@ -667,6 +671,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;