LineEdit: Fix and improve selection behaviour
This commit is contained in:
parent
55b83157e7
commit
99612207b7
|
@ -54,8 +54,17 @@ void LineEdit::_input_event(InputEvent p_event) {
|
||||||
|
|
||||||
if (b.pressed) {
|
if (b.pressed) {
|
||||||
|
|
||||||
|
shift_selection_check_pre(b.mod.shift);
|
||||||
|
|
||||||
set_cursor_at_pixel_pos(b.x);
|
set_cursor_at_pixel_pos(b.x);
|
||||||
|
|
||||||
|
if (b.mod.shift) {
|
||||||
|
|
||||||
|
selection_fill_at_cursor();
|
||||||
|
selection.creating=true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
if (b.doubleclick) {
|
if (b.doubleclick) {
|
||||||
|
|
||||||
selection.enabled=true;
|
selection.enabled=true;
|
||||||
|
@ -75,6 +84,7 @@ void LineEdit::_input_event(InputEvent p_event) {
|
||||||
|
|
||||||
selection.drag_attempt=true;
|
selection.drag_attempt=true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (!editable)
|
// if (!editable)
|
||||||
// non_editable_clicked_signal.call();
|
// non_editable_clicked_signal.call();
|
||||||
|
@ -339,8 +349,6 @@ void LineEdit::_input_event(InputEvent p_event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
selection.old_shift=k.mod.shift;
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -577,7 +585,7 @@ void LineEdit::undo() {
|
||||||
|
|
||||||
void LineEdit::shift_selection_check_pre(bool p_shift) {
|
void LineEdit::shift_selection_check_pre(bool p_shift) {
|
||||||
|
|
||||||
if (!selection.old_shift && p_shift) {
|
if (!selection.enabled && p_shift) {
|
||||||
selection.cursor_start=cursor_pos;
|
selection.cursor_start=cursor_pos;
|
||||||
}
|
}
|
||||||
if (!p_shift)
|
if (!p_shift)
|
||||||
|
@ -820,7 +828,6 @@ void LineEdit::selection_clear() {
|
||||||
selection.cursor_start=0;
|
selection.cursor_start=0;
|
||||||
selection.enabled=false;
|
selection.enabled=false;
|
||||||
selection.creating=false;
|
selection.creating=false;
|
||||||
selection.old_shift=false;
|
|
||||||
selection.doubleclick=false;
|
selection.doubleclick=false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -946,7 +953,6 @@ void LineEdit::select(int p_from, int p_to) {
|
||||||
selection.begin=p_from;
|
selection.begin=p_from;
|
||||||
selection.end=p_to;
|
selection.end=p_to;
|
||||||
selection.creating=false;
|
selection.creating=false;
|
||||||
selection.old_shift=false;
|
|
||||||
selection.doubleclick=false;
|
selection.doubleclick=false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,6 @@ private:
|
||||||
int cursor_start;
|
int cursor_start;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool creating;
|
bool creating;
|
||||||
bool old_shift;
|
|
||||||
bool doubleclick;
|
bool doubleclick;
|
||||||
bool drag_attempt;
|
bool drag_attempt;
|
||||||
} selection;
|
} selection;
|
||||||
|
|
Loading…
Reference in New Issue