diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-01-04 19:53:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-04 19:53:43 +0100 |
commit | 32bb236f2433041569218f85052088b85732ef4e (patch) | |
tree | e5ade8abdfbab325b8bc20a83c84dc2a85f5ff0c /scene | |
parent | 1f382ba4348c4ebdfc8bb4bcb5f07d017d009161 (diff) | |
parent | cc64679a2081ae1459fc4570acb41ad134c72ea3 (diff) |
Merge pull request #15334 from poke1024/textedit-mousepos
Fix TextEdit::_get_mouse_pos rounding errors
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/text_edit.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 87043c65eb..95c4b9058d 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1746,15 +1746,15 @@ void TextEdit::indent_left() { void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const { float rows = p_mouse.y; - rows -= cache.style_normal->get_margin(MARGIN_TOP); rows /= get_row_height(); - int lsp = get_line_scroll_pos(true); - int row = cursor.line_ofs + (rows + (round(v_scroll->get_value()) - lsp)); + rows += v_scroll->get_value(); + int row = Math::floor(rows); if (is_hiding_enabled()) { // row will be offset by the hidden rows - int f_ofs = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), MIN(rows + 1, text.size() - cursor.line_ofs)) - 1; - row = cursor.line_ofs + (f_ofs + (round(v_scroll->get_value()) - lsp)); + int lsp = get_line_scroll_pos(true); + int f_ofs = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), MIN(row + 1 - cursor.line_ofs, text.size() - cursor.line_ofs)) - 1; + row = cursor.line_ofs + f_ofs; row = CLAMP(row, 0, text.size() - num_lines_from(text.size() - 1, -1)); } |