Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2] [iOS] Keyboard input changes #43560

Merged
merged 3 commits into from
Dec 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
GUI: use cursor in TextEdit for non selected text.
  • Loading branch information
naithar committed Dec 16, 2020
commit f1fd0440f38ed212469395e9aa44b86894005664
17 changes: 10 additions & 7 deletions scene/gui/text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,16 +1756,19 @@ void TextEdit::_notification(int p_what) {
OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);

if (OS::get_singleton()->has_virtual_keyboard() && virtual_keyboard_enabled) {
String text = _base_get_text(0, 0, selection.selecting_line, selection.selecting_column);
int cursor_start = text.length();
int cursor_start = -1;
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 (!selection.active) {
String full_text = _base_get_text(0, 0, cursor.line, cursor.column);

if (selected_text.length() > 0) {
cursor_end = cursor_start + selected_text.length();
}
cursor_start = full_text.length();
} else {
String pre_text = _base_get_text(0, 0, selection.from_line, selection.from_column);
String post_text = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);

cursor_start = pre_text.length();
cursor_end = cursor_start + post_text.length();
}

OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect(), true, -1, cursor_start, cursor_end);
Expand Down