Skip to content

Commit

Permalink
Fix PopupMenu size calculations not taking into account control/can…
Browse files Browse the repository at this point in the history
…vas scale
  • Loading branch information
rsubtil committed Jul 20, 2024
1 parent 9a6b424 commit 1cf5036
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scene/gui/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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;

Expand Down

0 comments on commit 1cf5036

Please sign in to comment.