Merge pull request #46527 from kuruk-mm/3_2_lineedit
This commit is contained in:
commit
d252ef4c5e
2 changed files with 29 additions and 6 deletions
|
@ -88,12 +88,34 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (b->is_doubleclick() && selecting_enabled) {
|
if (selecting_enabled) {
|
||||||
|
if (!b->is_doubleclick() && (OS::get_singleton()->get_ticks_msec() - selection.last_dblclk) < 600) {
|
||||||
selection.enabled = true;
|
// Triple-click select all.
|
||||||
selection.begin = 0;
|
selection.enabled = true;
|
||||||
selection.end = text.length();
|
selection.begin = 0;
|
||||||
selection.doubleclick = true;
|
selection.end = text.length();
|
||||||
|
selection.doubleclick = true;
|
||||||
|
selection.last_dblclk = 0;
|
||||||
|
} else if (b->is_doubleclick()) {
|
||||||
|
// Double-click select word.
|
||||||
|
selection.enabled = true;
|
||||||
|
int beg = cursor_pos;
|
||||||
|
int end = beg;
|
||||||
|
bool symbol = beg < text.length() && is_symbol(text[beg]);
|
||||||
|
while (beg > 0 && text[beg - 1] > 32 && (symbol == is_symbol(text[beg - 1]))) {
|
||||||
|
beg--;
|
||||||
|
}
|
||||||
|
while (end < text.length() && text[end + 1] > 32 && (symbol == is_symbol(text[end + 1]))) {
|
||||||
|
end++;
|
||||||
|
}
|
||||||
|
if (end < text.length()) {
|
||||||
|
end += 1;
|
||||||
|
}
|
||||||
|
selection.begin = beg;
|
||||||
|
selection.end = end;
|
||||||
|
selection.doubleclick = true;
|
||||||
|
selection.last_dblclk = OS::get_singleton()->get_ticks_msec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selection.drag_attempt = false;
|
selection.drag_attempt = false;
|
||||||
|
|
|
@ -104,6 +104,7 @@ private:
|
||||||
bool creating;
|
bool creating;
|
||||||
bool doubleclick;
|
bool doubleclick;
|
||||||
bool drag_attempt;
|
bool drag_attempt;
|
||||||
|
uint64_t last_dblclk = 0;
|
||||||
} selection;
|
} selection;
|
||||||
|
|
||||||
struct TextOperation {
|
struct TextOperation {
|
||||||
|
|
Loading…
Reference in a new issue