Merge pull request #19541 from SaracenOne/ime2
Make LineEdit IME position hook ignore placeholder text
This commit is contained in:
commit
ea5512fc25
1 changed files with 5 additions and 4 deletions
|
@ -610,7 +610,8 @@ void LineEdit::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int x_ofs = 0;
|
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) {
|
switch (align) {
|
||||||
|
|
||||||
|
@ -645,9 +646,9 @@ void LineEdit::_notification(int p_what) {
|
||||||
Color font_color_selected = get_color("font_color_selected");
|
Color font_color_selected = get_color("font_color_selected");
|
||||||
Color cursor_color = get_color("cursor_color");
|
Color cursor_color = get_color("cursor_color");
|
||||||
|
|
||||||
const String &t = text.empty() ? placeholder : text;
|
const String &t = using_placeholder ? placeholder : text;
|
||||||
// draw placeholder color
|
// draw placeholder color
|
||||||
if (text.empty())
|
if (using_placeholder)
|
||||||
font_color.a *= placeholder_alpha;
|
font_color.a *= placeholder_alpha;
|
||||||
font_color.a *= disabled_alpha;
|
font_color.a *= disabled_alpha;
|
||||||
|
|
||||||
|
@ -757,7 +758,7 @@ void LineEdit::_notification(int p_what) {
|
||||||
if (has_focus()) {
|
if (has_focus()) {
|
||||||
|
|
||||||
OS::get_singleton()->set_ime_active(true);
|
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);
|
OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
Loading…
Reference in a new issue