summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-01-14 17:20:33 -0300
committerJuan Linietsky <reduzio@gmail.com>2019-01-14 17:20:54 -0300
commit6af8b7c955653c1df0dcc8790b522a1c79218ddf (patch)
treea4796c36c42b1ef2461bb3f94ebd860882ce0606
parent7346afb0eed10398d3a60dadcbd028878ecd8c29 (diff)
Defer activated signal after tree has been traversed.
-rw-r--r--scene/gui/tree.cpp16
-rw-r--r--scene/gui/tree.h2
2 files changed, 17 insertions, 1 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 8fad49a0d2..d2411d97e3 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1602,6 +1602,7 @@ void Tree::_range_click_timeout() {
mb.instance();
;
+ propagate_mouse_activated = false; //done from outside, so signal handler cant clear the tree in the middle of emit(which is a common case)
blocked++;
propagate_mouse_event(pos + cache.offset, 0, 0, false, root, BUTTON_LEFT, mb);
blocked--;
@@ -1615,6 +1616,11 @@ void Tree::_range_click_timeout() {
if (!click_handled)
range_click_timer->stop();
+ if (propagate_mouse_activated) {
+ emit_signal("item_activated");
+ propagate_mouse_activated = false;
+ }
+
} else {
range_click_timer->stop();
}
@@ -1723,7 +1729,8 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
if (p_doubleclick && (!c.editable || c.mode == TreeItem::CELL_MODE_CUSTOM || c.mode == TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it's confusing for check
- emit_signal("item_activated");
+ propagate_mouse_activated = true;
+
incr_search.clear();
return -1;
}
@@ -2591,6 +2598,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
click_handled = false;
pressing_for_editor = false;
+ propagate_mouse_activated = false;
blocked++;
propagate_mouse_event(pos + cache.offset, 0, 0, b->is_doubleclick(), root, b->get_button_index(), b);
@@ -2628,6 +2636,11 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
}
+ if (propagate_mouse_activated) {
+ emit_signal("item_activated");
+ propagate_mouse_activated = false;
+ }
+
} break;
case BUTTON_WHEEL_UP: {
@@ -3945,6 +3958,7 @@ Tree::Tree() {
cache.hover_cell = -1;
allow_reselect = false;
+ propagate_mouse_activated = false;
}
Tree::~Tree() {
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 84eccbf560..26d64baafb 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -329,6 +329,8 @@ private:
bool range_drag_enabled;
Vector2 range_drag_capture_pos;
+ bool propagate_mouse_activated;
+
//TreeItem *cursor_item;
//int cursor_column;