diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-06-13 18:52:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-13 18:52:43 +0200 |
commit | ea5512fc25bd2db55c2bf7f5e1d76a8c3f1ce051 (patch) | |
tree | dba6dfeac409d4d20047fb9103ebe059f8af3745 /scene/gui/line_edit.cpp | |
parent | 8efbe9ed3dc51e89d032cc2464cfe96fa9e4ea78 (diff) | |
parent | 9d0bdf69c46138748023714a1a402b035e9ee469 (diff) |
Merge pull request #19541 from SaracenOne/ime2
Make LineEdit IME position hook ignore placeholder text
Diffstat (limited to 'scene/gui/line_edit.cpp')
-rw-r--r-- | scene/gui/line_edit.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 71cb01d2ee..2ab7149886 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -610,7 +610,8 @@ void LineEdit::_notification(int p_what) { } int x_ofs = 0; - int cached_text_width = text.empty() ? cached_placeholder_width : cached_width; + bool using_placeholder = text.empty(); + int cached_text_width = using_placeholder ? cached_placeholder_width : cached_width; switch (align) { @@ -645,9 +646,9 @@ void LineEdit::_notification(int p_what) { Color font_color_selected = get_color("font_color_selected"); Color cursor_color = get_color("cursor_color"); - const String &t = text.empty() ? placeholder : text; + const String &t = using_placeholder ? placeholder : text; // draw placeholder color - if (text.empty()) + if (using_placeholder) font_color.a *= placeholder_alpha; font_color.a *= disabled_alpha; @@ -757,7 +758,7 @@ void LineEdit::_notification(int p_what) { if (has_focus()) { OS::get_singleton()->set_ime_active(true); - OS::get_singleton()->set_ime_position(get_global_position() + Point2(x_ofs, y_ofs + caret_height)); + OS::get_singleton()->set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height)); OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this); } } break; |