浏览代码

Check if old mouse column is still available.

(cherry picked from commit 79802b31a99f2b7256ad6d22e664734ee3a11397)
Marcel Admiraal 5 年之前
父节点
当前提交
f26131fca5
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9 4
      scene/gui/tree.cpp

+ 9 - 4
scene/gui/tree.cpp

@@ -2514,11 +2514,16 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
 				cache.hover_cell = col;
 
 				if (it != old_it || col != old_col) {
-					// Only need to update if mouse enters/exits a button
-					bool was_over_button = old_it && old_it->cells[old_col].custom_button;
-					bool is_over_button = it && it->cells[col].custom_button;
-					if (was_over_button || is_over_button) {
+					if (old_it && old_col >= old_it->cells.size()) {
+						// Columns may have changed since last update().
 						update();
+					} else {
+						// Only need to update if mouse enters/exits a button
+						bool was_over_button = old_it && old_it->cells[old_col].custom_button;
+						bool is_over_button = it && it->cells[col].custom_button;
+						if (was_over_button || is_over_button) {
+							update();
+						}
 					}
 				}
 			}