From 2d4ef1c193d57e8af4175564845a01a6fff0eff4 Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Fri, 11 Dec 2020 10:53:55 +0300 Subject: [PATCH] Fixed mouse scrolling in TextEdit's --- scene/gui/text_edit.cpp | 8 +++++--- scene/gui/text_edit.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6b168067894..1d65abc95fc 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1650,7 +1650,7 @@ void TextEdit::_notification(int p_what) { if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) { DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id()); - DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + _get_cursor_pixel_pos(), get_viewport()->get_window_id()); + DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + _get_cursor_pixel_pos(false), get_viewport()->get_window_id()); } if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { @@ -2072,8 +2072,10 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co r_col = col; } -Vector2i TextEdit::_get_cursor_pixel_pos() { - adjust_viewport_to_cursor(); +Vector2i TextEdit::_get_cursor_pixel_pos(bool p_adjust_viewport) { + if (p_adjust_viewport) { + adjust_viewport_to_cursor(); + } int row = 1; for (int i = get_first_visible_line(); i < cursor.line; i++) { if (!is_line_hidden(i)) { diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index c2fe4afec5d..3f16ed1366b 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -700,7 +700,7 @@ public: int cursor_get_column() const; int cursor_get_line() const; - Vector2i _get_cursor_pixel_pos(); + Vector2i _get_cursor_pixel_pos(bool p_adjust_viewport = true); bool cursor_get_blink_enabled() const; void cursor_set_blink_enabled(const bool p_enabled);