summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2016-04-03 19:29:26 +0200
committerRémi Verschelde <remi@verschelde.fr>2016-04-03 19:29:26 +0200
commite971112f4abc8a89089f4cb500863867a4e88ec6 (patch)
tree225a85d6053b5c7440d0d6a75724c2ec75ac5001
parent391095e0efe075268b892ff47a5885f5a6e2706f (diff)
parenta984adb5a6bde78c3b3c7681ad529cf22f2452ec (diff)
Merge pull request #4218 from Paulb23/text_edit_insert_mode
Fixed insert mode interaction with selection and autocomplete
-rw-r--r--scene/gui/text_edit.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index d6575481c2..4be8dd850c 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1596,7 +1596,22 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if(auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
_consume_pair_symbol(chr[0]);
} else {
+
+ // remove the old character if in insert mode
+ if (insert_mode) {
+ _begin_compex_operation();
+
+ // make sure we don't try and remove empty space
+ if (cursor.column < get_line(cursor.line).length()) {
+ _remove_text(cursor.line, cursor.column, cursor.line, cursor.column + 1);
+ }
+ }
+
_insert_text_at_cursor(chr);
+
+ if (insert_mode) {
+ _end_compex_operation();
+ }
}
}
@@ -1625,8 +1640,10 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
k.mod.shift=false;
}
- // stuff to do when selection is active..
+ // save here for insert mode, just in case it is cleared in the following section
+ bool had_selection = selection.active;
+ // stuff to do when selection is active..
if (selection.active) {
if (readonly)
@@ -2376,8 +2393,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (readonly)
break;
- // remove the old character if in insert mode
- if (insert_mode) {
+ // remove the old character if in insert mode and no selection
+ if (insert_mode && !had_selection) {
_begin_compex_operation();
// make sure we don't try and remove empty space
@@ -2397,7 +2414,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
_insert_text_at_cursor(chr);
}
- if (insert_mode) {
+ if (insert_mode && !had_selection) {
_end_compex_operation();
}
accept_event();