-fix TextEdit shift-click functionality past begin and end of selection (#1004)
This commit is contained in:
parent
fbfb87ec4f
commit
8a28af024e
@ -1152,19 +1152,55 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
||||
|
||||
if (mb.mod.shift && (cursor.column!=prev_col || cursor.line!=prev_line)) {
|
||||
|
||||
if (!selection.active) {
|
||||
selection.active=true;
|
||||
selection.selecting_mode=Selection::MODE_POINTER;
|
||||
selection.from_column=prev_col;
|
||||
selection.from_line=prev_line;
|
||||
selection.to_column=cursor.column;
|
||||
selection.to_line=cursor.line;
|
||||
if (selection.from_column>selection.to_column) {
|
||||
|
||||
if (selection.from_line>selection.to_line || (selection.from_line==selection.to_line && selection.from_column>selection.to_column)) {
|
||||
SWAP(selection.from_column,selection.to_column);
|
||||
SWAP(selection.from_line,selection.to_line);
|
||||
selection.shiftclick_left=false;
|
||||
} else {
|
||||
selection.shiftclick_left=true;
|
||||
}
|
||||
selection.selecting_line=prev_line;
|
||||
selection.selecting_column=prev_col;
|
||||
update();
|
||||
} else {
|
||||
|
||||
if (cursor.line<selection.from_line || (cursor.line==selection.from_line && cursor.column<=selection.from_column)) {
|
||||
selection.from_column=cursor.column;
|
||||
selection.from_line=cursor.line;
|
||||
} else if (cursor.line>selection.to_line || (cursor.line==selection.to_line && cursor.column>=selection.to_column)) {
|
||||
selection.to_column=cursor.column;
|
||||
selection.to_line=cursor.line;
|
||||
|
||||
} else if (!selection.shiftclick_left) {
|
||||
|
||||
selection.from_column=cursor.column;
|
||||
selection.from_line=cursor.line;
|
||||
} else {
|
||||
|
||||
selection.to_column=cursor.column;
|
||||
selection.to_line=cursor.line;
|
||||
}
|
||||
|
||||
if (selection.from_line>selection.to_line || (selection.from_line==selection.to_line && selection.from_column>selection.to_column)) {
|
||||
SWAP(selection.from_column,selection.to_column);
|
||||
SWAP(selection.from_line,selection.to_line);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -63,6 +63,7 @@ class TextEdit : public Control {
|
||||
int from_line,from_column;
|
||||
int to_line,to_column;
|
||||
|
||||
bool shiftclick_left;
|
||||
|
||||
} selection;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user