Fix richtextlabel meta links shouldn't open when swiping to scroll

This commit is contained in:
dennisseong 2018-10-09 09:04:59 +09:00
parent e6cfaa18ca
commit 14c0b75b63
2 changed files with 23 additions and 6 deletions

View file

@ -776,6 +776,7 @@ void RichTextLabel::_update_scroll() {
_validate_line_caches(main); _validate_line_caches(main);
} }
} }
scroll_updated = true;
} }
void RichTextLabel::_notification(int p_what) { void RichTextLabel::_notification(int p_what) {
@ -928,6 +929,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
if (true) { if (true) {
if (b->is_pressed() && !b->is_doubleclick()) { if (b->is_pressed() && !b->is_doubleclick()) {
scroll_updated = false;
int line = 0; int line = 0;
Item *item = NULL; Item *item = NULL;
@ -936,12 +938,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
if (item) { if (item) {
Variant meta; if (selection.enabled) {
if (!outside && _find_meta(item, &meta)) {
//meta clicked
emit_signal("meta_clicked", meta);
} else if (selection.enabled) {
selection.click = item; selection.click = item;
selection.click_char = line; selection.click_char = line;
@ -990,6 +987,24 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
} else if (!b->is_pressed()) { } else if (!b->is_pressed()) {
selection.click = NULL; selection.click = NULL;
if (!b->is_doubleclick() && !scroll_updated) {
int line = 0;
Item *item = NULL;
bool outside;
_find_click(main, b->get_position(), &item, &line, &outside);
if (item) {
Variant meta;
if (!outside && _find_meta(item, &meta)) {
//meta clicked
emit_signal("meta_clicked", meta);
}
}
}
} }
} }
} }
@ -2323,6 +2338,7 @@ RichTextLabel::RichTextLabel() {
updating_scroll = false; updating_scroll = false;
scroll_active = true; scroll_active = true;
scroll_w = 0; scroll_w = 0;
scroll_updated = false;
vscroll = memnew(VScrollBar); vscroll = memnew(VScrollBar);
add_child(vscroll); add_child(vscroll);

View file

@ -225,6 +225,7 @@ private:
bool scroll_following; bool scroll_following;
bool scroll_active; bool scroll_active;
int scroll_w; int scroll_w;
bool scroll_updated;
bool updating_scroll; bool updating_scroll;
int current_idx; int current_idx;
int visible_line_count; int visible_line_count;