Fix LineEdit's placeholder text being selected when double clicking

This commit is contained in:
Artemy Fedotov 2025-09-25 12:05:48 +04:00
parent 6e4e8072e1
commit 40d56c98bc
No known key found for this signature in database
GPG key ID: C98F659A7C4525DA

View file

@ -480,12 +480,12 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) {
selection.creating = true; selection.creating = true;
} else { } else {
if (selecting_enabled) { if (selecting_enabled && !text.is_empty()) {
const int triple_click_timeout = 600; const int triple_click_timeout = 600;
const int triple_click_tolerance = 5; const int triple_click_tolerance = 5;
const bool is_triple_click = !b->is_double_click() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < triple_click_timeout && b->get_position().distance_to(last_dblclk_pos) < triple_click_tolerance; const bool is_triple_click = !b->is_double_click() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < triple_click_timeout && b->get_position().distance_to(last_dblclk_pos) < triple_click_tolerance;
if (is_triple_click && !text.is_empty()) { if (is_triple_click) {
// Triple-click select all. // Triple-click select all.
selection.enabled = true; selection.enabled = true;
selection.begin = 0; selection.begin = 0;