diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-12-11 18:00:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-11 18:00:48 +0100 |
commit | 4c41e29c8e796f97a714da784a7cecae8933b202 (patch) | |
tree | c36b06c9a91503d5af39c4f973908cff39194608 /scene/gui/line_edit.cpp | |
parent | 573956915efefb1cda0a5349c7e7aaeb0363df1d (diff) | |
parent | 4554c682e6c9749116c79313d6f08cd6e8b7e6e6 (diff) |
Merge pull request #23923 from bruvzg/ime_gdscript
Changes IME to make it possible to use it from gdscript/gdnative
Diffstat (limited to 'scene/gui/line_edit.cpp')
-rw-r--r-- | scene/gui/line_edit.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 299c304c5f..42d7f1b080 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -831,7 +831,6 @@ void LineEdit::_notification(int p_what) { OS::get_singleton()->set_ime_active(true); 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; case NOTIFICATION_FOCUS_ENTER: { @@ -843,7 +842,6 @@ void LineEdit::_notification(int p_what) { OS::get_singleton()->set_ime_active(true); Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height; OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos); - OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this); if (OS::get_singleton()->has_virtual_keyboard()) OS::get_singleton()->show_virtual_keyboard(text, get_global_rect()); @@ -852,7 +850,6 @@ void LineEdit::_notification(int p_what) { case NOTIFICATION_FOCUS_EXIT: { OS::get_singleton()->set_ime_position(Point2()); - OS::get_singleton()->set_ime_intermediate_text_callback(NULL, NULL); OS::get_singleton()->set_ime_active(false); ime_text = ""; ime_selection = Point2(); @@ -861,6 +858,12 @@ void LineEdit::_notification(int p_what) { OS::get_singleton()->hide_virtual_keyboard(); } break; + case MainLoop::NOTIFICATION_OS_IME_UPDATE: { + + ime_text = OS::get_singleton()->get_ime_text(); + ime_selection = OS::get_singleton()->get_ime_selection(); + update(); + } break; } } @@ -1461,13 +1464,6 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) { update(); } -void LineEdit::_ime_text_callback(void *p_self, String p_text, Point2 p_selection) { - LineEdit *self = (LineEdit *)p_self; - self->ime_text = p_text; - self->ime_selection = p_selection; - self->update(); -} - void LineEdit::_text_changed() { if (expand_to_text_length) |