summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorgeequlim <geequlim@gmail.com>2017-06-25 23:50:45 +0800
committergeequlim <geequlim@gmail.com>2017-07-11 18:36:20 +0800
commit7358766ff69e064d8a31b18c54e3c1e22e303cb6 (patch)
treee68eeea815da389c2fc36c878a745135499824c6 /scene/gui
parenta5d500f0233913fe7622434225c5dc73ebaccd1e (diff)
IME window follow the input cursor.
Abstruct set_ime_position to OS class. Update ime position for LineEdit and TextEdit.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/line_edit.cpp10
-rw-r--r--scene/gui/text_edit.cpp9
2 files changed, 19 insertions, 0 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index bc579020bd..8d3271ca8c 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -660,6 +660,11 @@ void LineEdit::_notification(int p_what) {
Point2(x_ofs, y_ofs), Size2(1, caret_height)),
cursor_color);
}
+
+ if (has_focus()) {
+
+ OS::get_singleton()->set_ime_position(get_global_position() + Point2(x_ofs, y_ofs + caret_height));
+ }
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -667,12 +672,17 @@ void LineEdit::_notification(int p_what) {
draw_caret = true;
}
+ Point2 cursor_pos = Point2(get_cursor_pos(), 1) * get_minimum_size().height;
+ OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect());
} break;
case NOTIFICATION_FOCUS_EXIT: {
+ OS::get_singleton()->set_ime_position(Point2());
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 936a9b77f8..ffa23ce771 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1191,12 +1191,19 @@ void TextEdit::_notification(int p_what) {
}
}
+ if (has_focus()) {
+ OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()));
+ }
} break;
case NOTIFICATION_FOCUS_ENTER: {
if (!caret_blink_enabled) {
draw_caret = true;
}
+
+ Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
+ OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect());
if (raised_from_completion) {
@@ -1206,6 +1213,8 @@ void TextEdit::_notification(int p_what) {
} break;
case NOTIFICATION_FOCUS_EXIT: {
+ OS::get_singleton()->set_ime_position(Point2());
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
if (raised_from_completion) {