-fix TextEdit shift-click functionality past begin and end of selection (#1004)
This commit is contained in:
parent
fbfb87ec4f
commit
8a28af024e
2 changed files with 2751 additions and 2714 deletions
|
@ -26,7 +26,7 @@
|
|||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
/*****f********************************************/
|
||||
/*****f********************************************/
|
||||
/* text_edit.cpp */
|
||||
/*************************************************/
|
||||
/* This file is part of: */
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -1963,7 +1999,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
|||
|
||||
if (scancode_handled)
|
||||
accept_event();
|
||||
/*
|
||||
/*
|
||||
if (!scancode_handled && !k.mod.command && !k.mod.alt) {
|
||||
|
||||
if (k.unicode>=32) {
|
||||
|
@ -2321,7 +2357,7 @@ void TextEdit::adjust_viewport_to_cursor() {
|
|||
cursor.x_ofs=cursor_x;
|
||||
|
||||
update();
|
||||
/*
|
||||
/*
|
||||
get_range()->set_max(text.size());
|
||||
|
||||
get_range()->set_page(get_visible_rows());
|
||||
|
@ -3298,7 +3334,7 @@ void TextEdit::_update_completion_candidates() {
|
|||
if (completion_options.size()==1) {
|
||||
//one option to complete, just complete it automagically
|
||||
_confirm_completion();
|
||||
// insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length()));
|
||||
// insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length()));
|
||||
_cancel_completion();
|
||||
return;
|
||||
|
||||
|
@ -3338,7 +3374,7 @@ void TextEdit::code_complete(const Vector<String> &p_strings) {
|
|||
completion_current="";
|
||||
completion_index=0;
|
||||
_update_completion_candidates();
|
||||
//
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
@ -3424,7 +3460,7 @@ void TextEdit::_bind_methods() {
|
|||
BIND_CONSTANT( SEARCH_WHOLE_WORDS );
|
||||
BIND_CONSTANT( SEARCH_BACKWARDS );
|
||||
|
||||
/*
|
||||
/*
|
||||
ObjectTypeDB::bind_method(_MD("delete_char"),&TextEdit::delete_char);
|
||||
ObjectTypeDB::bind_method(_MD("delete_line"),&TextEdit::delete_line);
|
||||
*/
|
||||
|
@ -3497,8 +3533,8 @@ TextEdit::TextEdit() {
|
|||
tab_size=4;
|
||||
text.set_tab_size(tab_size);
|
||||
text.clear();
|
||||
// text.insert(1,"Mongolia..");
|
||||
// text.insert(2,"PAIS GENEROSO!!");
|
||||
// text.insert(1,"Mongolia..");
|
||||
// text.insert(2,"PAIS GENEROSO!!");
|
||||
text.set_color_regions(&color_regions);
|
||||
|
||||
h_scroll = memnew( HScrollBar );
|
||||
|
|
|
@ -63,6 +63,7 @@ class TextEdit : public Control {
|
|||
int from_line,from_column;
|
||||
int to_line,to_column;
|
||||
|
||||
bool shiftclick_left;
|
||||
|
||||
} selection;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue