diff options
author | Sergey Minakov <naithar@icloud.com> | 2020-11-15 15:09:20 +0300 |
---|---|---|
committer | Sergey Minakov <naithar@icloud.com> | 2020-11-15 16:03:21 +0300 |
commit | 8894c64e54f25a37f2594bb1dd34075084a99ae1 (patch) | |
tree | 62aba55e4434d0e086452c3271007c158ac372d6 /scene/gui | |
parent | 6adfc6188c455ebc974a2faf3e86facd4345719e (diff) |
GUI: send cursor data from TextEdit
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/text_edit.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index cbe6c6bdb9..77ac3d6702 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1559,7 +1559,19 @@ void TextEdit::_notification(int p_what) { } if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { - DisplayServer::get_singleton()->virtual_keyboard_show(get_text(), get_global_rect(), true); + String text = _base_get_text(0, 0, selection.selecting_line, selection.selecting_column); + int cursor_start = text.length(); + int cursor_end = -1; + + if (selection.active) { + String selected_text = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); + + if (selected_text.length() > 0) { + cursor_end = cursor_start + selected_text.length(); + } + } + + DisplayServer::get_singleton()->virtual_keyboard_show(get_text(), get_global_rect(), true, -1, cursor_start, cursor_end); } } break; case NOTIFICATION_FOCUS_EXIT: { |