summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-01-03 21:33:12 +0100
committerGitHub <noreply@github.com>2019-01-03 21:33:12 +0100
commit65a86ae17c442163c424fe4b229a64d48da0fc89 (patch)
treef42f812da956eb410b603c315b8f4fc8e4216012
parent1808241d168cffe20b05f25882173dca1706265d (diff)
parent615ca1d59e5e40487cdf22a87fc31e01c0556df5 (diff)
Merge pull request #24683 from SoIAS/autocompletion_menu_position_24674
Fixed autocompletion menu vertical position
-rw-r--r--scene/gui/text_edit.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 4607e55057..7577ee22ab 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -802,6 +802,7 @@ void TextEdit::_notification(int p_what) {
}
Point2 cursor_pos;
+ int cursor_insert_offset_y = 0;
// get the highlighted words
String highlighted_text = get_selection_text();
@@ -1111,7 +1112,8 @@ void TextEdit::_notification(int p_what) {
cursor_pos.y += (get_row_height() - cache.font->get_height()) / 2;
if (insert_mode) {
- cursor_pos.y += (cache.font->get_height() - 3);
+ cursor_insert_offset_y = (cache.font->get_height() - 3);
+ cursor_pos.y += cursor_insert_offset_y;
}
int caret_w = (str[j] == '\t') ? cache.font->get_char_size(' ').width : char_w;
@@ -1203,7 +1205,8 @@ void TextEdit::_notification(int p_what) {
cursor_pos.y += (get_row_height() - cache.font->get_height()) / 2;
if (insert_mode) {
- cursor_pos.y += (cache.font->get_height() - 3);
+ cursor_insert_offset_y = cache.font->get_height() - 3;
+ cursor_pos.y += cursor_insert_offset_y;
}
if (ime_text.length() > 0) {
int ofs = 0;
@@ -1291,9 +1294,9 @@ void TextEdit::_notification(int p_what) {
int th = h + csb->get_minimum_size().y;
if (cursor_pos.y + get_row_height() + th > get_size().height) {
- completion_rect.position.y = cursor_pos.y - th;
+ completion_rect.position.y = cursor_pos.y - th - (cache.line_spacing / 2.0f) - cursor_insert_offset_y;
} else {
- completion_rect.position.y = cursor_pos.y + get_row_height() + csb->get_offset().y - cache.font->get_height();
+ completion_rect.position.y = cursor_pos.y + cache.font->get_height() + (cache.line_spacing / 2.0f) + csb->get_offset().y - cursor_insert_offset_y;
completion_below = true;
}