LineEdit: Fix and improve selection behaviour
(cherry picked from commit 99612207b7
)
This commit is contained in:
parent
a04a78c7f6
commit
18cb1f8e44
|
@ -46,8 +46,17 @@ void LineEdit::_input_event(InputEvent p_event) {
|
|||
|
||||
if (b.pressed) {
|
||||
|
||||
shift_selection_check_pre(b.mod.shift);
|
||||
|
||||
set_cursor_at_pixel_pos(b.x);
|
||||
|
||||
if (b.mod.shift) {
|
||||
|
||||
selection_fill_at_cursor();
|
||||
selection.creating=true;
|
||||
|
||||
} else {
|
||||
|
||||
if (b.doubleclick) {
|
||||
|
||||
selection.enabled=true;
|
||||
|
@ -67,6 +76,7 @@ void LineEdit::_input_event(InputEvent p_event) {
|
|||
|
||||
selection.drag_attempt=true;
|
||||
}
|
||||
}
|
||||
|
||||
// if (!editable)
|
||||
// non_editable_clicked_signal.call();
|
||||
|
@ -345,8 +355,6 @@ void LineEdit::_input_event(InputEvent p_event) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
selection.old_shift=k.mod.shift;
|
||||
update();
|
||||
|
||||
}
|
||||
|
@ -561,7 +569,7 @@ void LineEdit::paste_text() {
|
|||
|
||||
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;
|
||||
}
|
||||
if (!p_shift)
|
||||
|
@ -803,7 +811,6 @@ void LineEdit::selection_clear() {
|
|||
selection.cursor_start=0;
|
||||
selection.enabled=false;
|
||||
selection.creating=false;
|
||||
selection.old_shift=false;
|
||||
selection.doubleclick=false;
|
||||
update();
|
||||
}
|
||||
|
@ -929,7 +936,6 @@ void LineEdit::select(int p_from, int p_to) {
|
|||
selection.begin=p_from;
|
||||
selection.end=p_to;
|
||||
selection.creating=false;
|
||||
selection.old_shift=false;
|
||||
selection.doubleclick=false;
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ private:
|
|||
int cursor_start;
|
||||
bool enabled;
|
||||
bool creating;
|
||||
bool old_shift;
|
||||
bool doubleclick;
|
||||
bool drag_attempt;
|
||||
} selection;
|
||||
|
|
Loading…
Reference in New Issue