summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/text_edit.cpp18
-rw-r--r--scene/gui/text_edit.h1
2 files changed, 18 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 1b3935dd25..985abf8e55 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1584,6 +1584,12 @@ void TextEdit::_move_cursor_left(bool p_select, bool p_move_by_word) {
// Handle selection
if (p_select) {
_pre_shift_selection();
+ } else if (selection.active && !p_move_by_word) {
+ // If a selection is active, move cursor to start of selection
+ cursor_set_line(selection.from_line);
+ cursor_set_column(selection.from_column);
+ deselect();
+ return;
} else {
deselect();
}
@@ -1629,6 +1635,12 @@ void TextEdit::_move_cursor_right(bool p_select, bool p_move_by_word) {
// Handle selection
if (p_select) {
_pre_shift_selection();
+ } else if (selection.active && !p_move_by_word) {
+ // If a selection is active, move cursor to end of selection
+ cursor_set_line(selection.to_line);
+ cursor_set_column(selection.to_column);
+ deselect();
+ return;
} else {
deselect();
}
@@ -2246,7 +2258,10 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
selection.selecting_column = col;
}
- if (!mb->is_double_click() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < 600 && cursor.line == prev_line) {
+ const int triple_click_timeout = 600;
+ const int triple_click_tolerance = 5;
+
+ if (!mb->is_double_click() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < triple_click_timeout && mb->get_position().distance_to(last_dblclk_pos) < triple_click_tolerance) {
// Triple-click select line.
selection.selecting_mode = SelectionMode::SELECTION_MODE_LINE;
_update_selection_mode_line();
@@ -2256,6 +2271,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
selection.selecting_mode = SelectionMode::SELECTION_MODE_WORD;
_update_selection_mode_word();
last_dblclk = OS::get_singleton()->get_ticks_msec();
+ last_dblclk_pos = mb->get_position();
}
update();
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 9e6dedb267..c5853786cf 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -308,6 +308,7 @@ private:
String lookup_symbol_word;
uint64_t last_dblclk = 0;
+ Vector2 last_dblclk_pos;
Timer *idle_detect;
Timer *click_select_held;