summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaracen <SaracenOne@gmail.com>2018-06-13 16:33:37 +0100
committerSaracen <SaracenOne@gmail.com>2018-06-13 16:42:36 +0100
commit9d0bdf69c46138748023714a1a402b035e9ee469 (patch)
tree27575a0c592e40fbdcf1af42989fe3f4153b93d4
parent1651dbb54df30dd189658b9cf9cd84f650be6bdc (diff)
LineEdit IME position will now ignore placeholder text.
-rw-r--r--scene/gui/line_edit.cpp9
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;