summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorvolzhs <volzhs@gmail.com>2017-03-03 03:51:23 +0900
committervolzhs <volzhs@gmail.com>2017-03-03 04:01:04 +0900
commit66b7586fb0239f3a67aecf34f4c7551d645b73e1 (patch)
treed07afb924283ce96d6cee412747f5edb0d1be71a /scene/gui
parent74eace2b14b337e23d0dc552f3bc3e60f1710f65 (diff)
Fix wrong TreeItem reference after reconstructing
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/tree.cpp5
-rw-r--r--scene/gui/tree.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index cd93c13c99..292efdcc01 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -848,7 +848,6 @@ void Tree::update_cache() {
cache.title_button_color = get_color("title_button_color");
v_scroll->set_custom_step(cache.font->get_height());
- cache.click_item=get_selected();
}
@@ -1611,6 +1610,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
cache.click_id=c.buttons[j].id;
cache.click_item=p_item;
cache.click_column=col;
+ cache.click_pos=get_global_mouse_pos()-get_global_pos();
update();
//emit_signal("button_pressed");
return -1;
@@ -2391,6 +2391,8 @@ void Tree::_gui_input(InputEvent p_event) {
if (cache.click_type==Cache::CLICK_BUTTON) {
+ // make sure in case of wrong reference after reconstructing whole TreeItems
+ cache.click_item=get_item_at_pos(cache.click_pos);
emit_signal("button_pressed",cache.click_item,cache.click_column,cache.click_id);
}
@@ -2971,7 +2973,6 @@ void Tree::clear() {
selected_item=NULL;
edited_item=NULL;
popup_edited_item=NULL;
- selected_item=NULL;
update();
};
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 351cc4cb50..14bd2efbaa 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -409,6 +409,7 @@ friend class TreeItem;
TreeItem *click_item;
int click_column;
int hover_index;
+ Point2 click_pos;
} cache;