Merge pull request #115760 from KoBeWi/Tree_should_be_illegal

Fix Tree item edit canceled instantly on scroll
This commit is contained in:
Thaddeus Crews
2026-06-18 13:15:22 -05:00
2 changed files with 12 additions and 1 deletions
+11 -1
View File
@@ -6083,7 +6083,14 @@ int Tree::get_columns() const {
void Tree::_scroll_moved(float) {
_determine_hovered_item();
queue_redraw();
popup_editor->hide();
if (scroll_pending > 0) {
// If both vertical and horizontal scroll happen in the same frame,
// this condition needs to cancel 2 movements, hence the counter.
scroll_pending--;
} else {
popup_editor->hide();
}
}
Rect2 Tree::get_custom_popup_rect() const {
@@ -6152,6 +6159,7 @@ void Tree::ensure_cursor_is_visible() {
v_scroll->set_value(y_offset);
} else if (y_offset + cell_h > v_scroll->get_value() + screen_h) {
delta_v = y_offset - screen_h + cell_h - v_scroll->get_value();
scroll_pending++;
callable_mp((Range *)v_scroll, &Range::set_value).call_deferred(y_offset - screen_h + cell_h);
} else if (y_offset < v_scroll->get_value()) {
delta_v = y_offset - v_scroll->get_value();
@@ -6171,9 +6179,11 @@ void Tree::ensure_cursor_is_visible() {
if (cell_w > screen_w) {
delta_h = x_offset - h_scroll->get_value();
scroll_pending++;
h_scroll->set_value(x_offset);
} else if (x_offset + cell_w > h_scroll->get_value() + screen_w) {
delta_h = x_offset - screen_w + cell_w - h_scroll->get_value();
scroll_pending++;
callable_mp((Range *)h_scroll, &Range::set_value).call_deferred(x_offset - screen_w + cell_w);
} else if (x_offset < h_scroll->get_value()) {
delta_h = x_offset - h_scroll->get_value();
+1
View File
@@ -556,6 +556,7 @@ private:
bool show_column_titles = false;
bool popup_edit_committed = true;
int scroll_pending = 0;
RID accessibility_scroll_element;
RID stylebox_ci; // Separate canvas item for drawing native styleboxes.
RID custom_ci; // Separate canvas item for drawing custom content.