Merge pull request #3029 from neikeq/textedit_select_imp
TextEdit: Scroll while selecting with mouse idle
This commit is contained in:
commit
8a94297105
2 changed files with 40 additions and 3 deletions
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "text_edit.h"
|
#include "text_edit.h"
|
||||||
#include "os/keyboard.h"
|
#include "os/keyboard.h"
|
||||||
|
#include "os/input.h"
|
||||||
#include "os/os.h"
|
#include "os/os.h"
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
@ -349,6 +350,29 @@ void TextEdit::_update_scrollbars() {
|
||||||
updating_scrolls=false;
|
updating_scrolls=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEdit::_click_selection_held() {
|
||||||
|
|
||||||
|
if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode!=Selection::MODE_NONE) {
|
||||||
|
|
||||||
|
Point2 mp = Input::get_singleton()->get_mouse_pos()-get_global_pos();
|
||||||
|
|
||||||
|
int row,col;
|
||||||
|
_get_mouse_pos(Point2i(mp.x,mp.y), row,col);
|
||||||
|
|
||||||
|
select(selection.selecting_line,selection.selecting_column,row,col);
|
||||||
|
|
||||||
|
cursor_set_line( row );
|
||||||
|
cursor_set_column( col );
|
||||||
|
update();
|
||||||
|
|
||||||
|
click_select_held->start();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
click_select_held->stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextEdit::_notification(int p_what) {
|
void TextEdit::_notification(int p_what) {
|
||||||
|
|
||||||
|
@ -1293,6 +1317,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (mb.button_index==BUTTON_LEFT)
|
||||||
|
click_select_held->stop();
|
||||||
|
|
||||||
// notify to show soft keyboard
|
// notify to show soft keyboard
|
||||||
notification(NOTIFICATION_FOCUS_ENTER);
|
notification(NOTIFICATION_FOCUS_ENTER);
|
||||||
}
|
}
|
||||||
|
@ -1304,17 +1331,19 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
||||||
|
|
||||||
if (mm.button_mask&BUTTON_MASK_LEFT) {
|
if (mm.button_mask&BUTTON_MASK_LEFT) {
|
||||||
|
|
||||||
|
if (selection.selecting_mode!=Selection::MODE_NONE) {
|
||||||
|
|
||||||
int row,col;
|
int row,col;
|
||||||
_get_mouse_pos(Point2i(mm.x,mm.y), row,col);
|
_get_mouse_pos(Point2i(mm.x,mm.y), row,col);
|
||||||
|
|
||||||
if (selection.selecting_mode!=Selection::MODE_NONE) {
|
|
||||||
|
|
||||||
select(selection.selecting_line,selection.selecting_column,row,col);
|
select(selection.selecting_line,selection.selecting_column,row,col);
|
||||||
|
|
||||||
cursor_set_line( row );
|
cursor_set_line( row );
|
||||||
cursor_set_column( col );
|
cursor_set_column( col );
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
click_select_held->start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3697,6 +3726,7 @@ void TextEdit::_bind_methods() {
|
||||||
ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
|
ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
|
||||||
ObjectTypeDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
|
ObjectTypeDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
|
||||||
ObjectTypeDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
|
ObjectTypeDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
|
||||||
|
ObjectTypeDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held);
|
||||||
|
|
||||||
BIND_CONSTANT( SEARCH_MATCH_CASE );
|
BIND_CONSTANT( SEARCH_MATCH_CASE );
|
||||||
BIND_CONSTANT( SEARCH_WHOLE_WORDS );
|
BIND_CONSTANT( SEARCH_WHOLE_WORDS );
|
||||||
|
@ -3812,6 +3842,11 @@ TextEdit::TextEdit() {
|
||||||
idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3));
|
idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3));
|
||||||
idle_detect->connect("timeout", this,"_push_current_op");
|
idle_detect->connect("timeout", this,"_push_current_op");
|
||||||
|
|
||||||
|
click_select_held = memnew( Timer );
|
||||||
|
add_child(click_select_held);
|
||||||
|
click_select_held->set_wait_time(0.05);
|
||||||
|
click_select_held->connect("timeout", this,"_click_selection_held");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
syntax_coloring=true;
|
syntax_coloring=true;
|
||||||
keywords["void"]=Color(0.3,0.0,0.1);
|
keywords["void"]=Color(0.3,0.0,0.1);
|
||||||
|
|
|
@ -219,6 +219,7 @@ class TextEdit : public Control {
|
||||||
uint64_t last_dblclk;
|
uint64_t last_dblclk;
|
||||||
|
|
||||||
Timer *idle_detect;
|
Timer *idle_detect;
|
||||||
|
Timer *click_select_held;
|
||||||
HScrollBar *h_scroll;
|
HScrollBar *h_scroll;
|
||||||
VScrollBar *v_scroll;
|
VScrollBar *v_scroll;
|
||||||
bool updating_scrolls;
|
bool updating_scrolls;
|
||||||
|
@ -240,6 +241,7 @@ class TextEdit : public Control {
|
||||||
void adjust_viewport_to_cursor();
|
void adjust_viewport_to_cursor();
|
||||||
void _scroll_moved(double);
|
void _scroll_moved(double);
|
||||||
void _update_scrollbars();
|
void _update_scrollbars();
|
||||||
|
void _click_selection_held();
|
||||||
|
|
||||||
void _pre_shift_selection();
|
void _pre_shift_selection();
|
||||||
void _post_shift_selection();
|
void _post_shift_selection();
|
||||||
|
|
Loading…
Reference in a new issue