diff options
| author | kbake | 2017-02-03 02:01:41 -0500 |
|---|---|---|
| committer | Rémi Verschelde | 2017-03-18 19:58:13 +0100 |
| commit | 31260bb7202fdd59084a4d820b401c93dfaea156 (patch) | |
| tree | 73600592ab71fa6d68b9411490575c82b66c0e2a | |
| parent | 97fef612fb7cffdf39eebbcedb1a2a80134ef16e (diff) | |
| download | godot-31260bb7202fdd59084a4d820b401c93dfaea156.tar.gz godot-31260bb7202fdd59084a4d820b401c93dfaea156.tar.zst godot-31260bb7202fdd59084a4d820b401c93dfaea156.zip | |
Selected text is now deselected on ctrl+home/end
This fixes Issue #7694 and also the error mentioned in the comments of that issue.
(cherry picked from commit 1169f4e040327c2353d29dccafa0e176eec56a0b)
| -rw-r--r-- | scene/gui/text_edit.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index f7e8893a2..13896a7c1 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2370,6 +2370,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (k.mod.shift) _post_shift_selection(); + else if(k.mod.command || k.mod.control) + deselect(); } break; #else @@ -2379,25 +2381,30 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (k.mod.shift) _pre_shift_selection(); - // compute whitespace symbols seq length - int current_line_whitespace_len = 0; - while(current_line_whitespace_len < text[cursor.line].length()) { - CharType c = text[cursor.line][current_line_whitespace_len]; - if(c != '\t' && c != ' ') - break; - current_line_whitespace_len++; - } - - if(cursor_get_column() == current_line_whitespace_len) + if (k.mod.command) { + cursor_set_line(0); cursor_set_column(0); - else - cursor_set_column(current_line_whitespace_len); + } + else { + // compute whitespace symbols seq length + int current_line_whitespace_len = 0; + while( current_line_whitespace_len < text[cursor.line].length() ) { + CharType c = text[cursor.line][current_line_whitespace_len]; + if( c != '\t' && c != ' ' ) + break; + current_line_whitespace_len++; + } - if (k.mod.command) - cursor_set_line(0); + if( cursor_get_column() == current_line_whitespace_len ) + cursor_set_column(0); + else + cursor_set_column(current_line_whitespace_len); + } if (k.mod.shift) _post_shift_selection(); + else if(k.mod.command || k.mod.control) + deselect(); _cancel_completion(); completion_hint=""; @@ -2420,6 +2427,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (k.mod.shift) _post_shift_selection(); + else if(k.mod.command || k.mod.control) + deselect(); } break; #else @@ -2434,6 +2443,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (k.mod.shift) _post_shift_selection(); + else if(k.mod.command || k.mod.control) + deselect(); _cancel_completion(); completion_hint=""; |
