Merge pull request #94559 from rsubtil/bugfix-popup_menu_size_calculations

[3.x] Fix `PopupMenu` size calculations not taking into account control/canvas scale
This commit is contained in:
Rémi Verschelde 2024-07-20 15:49:42 +02:00 committed by GitHub
commit 2cc5ca43ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -327,9 +327,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. // 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; 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; Ref<InputEventMouseButton> b = p_event;