Fix PopupMenu size calculations not taking into account control/canvas scale

This commit is contained in:
Ricardo Subtil 2024-07-20 12:46:25 +01:00 committed by Relintai
parent 2f27d74f3f
commit 39cae06fbf

View File

@ -353,9 +353,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
}
// Make an area which does not include v scrollbar, so that items are not activated when dragging scrollbar.
Rect2 item_clickable_area = control->get_global_rect();
Transform2D xform = get_global_transform_with_canvas();
Point2 item_origin = xform.get_origin();
float scroll_width = scroll_container->get_v_scrollbar()->is_visible_in_tree() ? scroll_container->get_v_scrollbar()->get_size().width : 0;
item_clickable_area.set_size(Size2(item_clickable_area.size.width - scroll_width, item_clickable_area.size.height));
Size2 item_size = (control->get_global_rect().get_size() - Vector2(scroll_width, 0)) * xform.get_scale();
Rect2 item_clickable_area = Rect2(item_origin, item_size);
Ref<InputEventMouseButton> b = p_event;