1
0
Fork 0

Fix problems with popup menus for `Tree`'s range items

This commit is contained in:
Michael Alexsander 2026-01-08 17:02:13 -03:00
parent 85c75da4ad
commit 3e942c7135
No known key found for this signature in database
GPG Key ID: A9C91EE110F4EABA
1 changed files with 11 additions and 1 deletions

View File

@ -3253,7 +3253,16 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
if (!c.text.is_empty()) {
_update_popup_menu(c);
popup_menu->set_size(Size2(col_width, 0));
popup_menu->set_position(get_screen_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h) - theme_cache.offset);
int pos_x = 0;
Point2 panel_ofs = theme_cache.panel_style->get_offset();
if (is_layout_rtl()) {
pos_x = get_size().width - col_ofs - panel_ofs.x - popup_menu->get_size().width;
} else {
pos_x = col_ofs + panel_ofs.x;
}
popup_menu->set_position(get_screen_position() + Point2i(pos_x, _get_title_button_height() + y_ofs + item_h + panel_ofs.y) - theme_cache.offset);
popup_menu->popup();
popup_edited_item = p_item;
popup_edited_item_col = col;
@ -3503,6 +3512,7 @@ void Tree::value_editor_changed(double p_value) {
void Tree::_update_popup_menu(const TreeItem::Cell &p_cell) {
if (popup_menu == nullptr) {
popup_menu = memnew(PopupMenu);
popup_menu->set_shrink_width(false);
popup_menu->hide();
add_child(popup_menu, false, INTERNAL_MODE_FRONT);
popup_menu->connect(SceneStringName(id_pressed), callable_mp(this, &Tree::popup_select));