Fix #156022: Menu auto scroll can stop at submenus buttons (Backport)

This includes 2 different commits from main, see individual commits for details.

Backport: Fix #156022: Menu auto scroll can stop at submenus buttons

When a button overlaps the auto scroll handler it not longer gets
completely hidden, instead the button is partially drawn, that makes
buttons to be interactive.

This prevents to open sub-menus or to highlight other buttons while
hovering auto scroll-handlers.

Fix Regression: Auto open menus not working after using menu auto scroll handlers

Mistake in 58aa355049

When using an auto-scroll handler for popups a timer is created to
handle the auto-scroll, however currently this timer is created just
once and when the mouse moves inside the popup or when the scroll hits
its minimum/maximum value the timer still remains active.

This removes the timer when the auto-scroll handler is not hovered
or it can't scroll anymore.

Also note that Pie menus are using the scrolltimer for popup animations,
so also allow auto-opening menu buttons on pie menus.

Pull Request: https://projects.blender.org/blender/blender/pulls/156049
This commit is contained in:
Guillermo Venegas 2026-04-09 12:37:21 +02:00 • committed by Thomas Dinges
parent a4b6ac33f0
commit 565a288afb
2 changed files with 17 additions and 4 deletions

View file

@ -9874,8 +9874,10 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, Button *but
if (event->customdata == data->autoopentimer) {
WM_event_timer_remove(data->wm, data->window, data->autoopentimer);
data->autoopentimer = nullptr;
if (button_contains_point_px(but, region, event->xy) || but->active) {
/* Do not open sub-menus while using an auto-scroll handler. */
if ((block_is_pie_menu(block) || !block->handle || !block->handle->scrolltimer) &&
(button_contains_point_px(but, region, event->xy) || but->active))
{
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
}
}
@ -10906,7 +10908,13 @@ static int ui_handle_menu_event(bContext *C,
}
else if (event->type == TIMER) {
if (event->customdata == menu->scrolltimer) {
ui_menu_scroll_to_y(region, block, my);
if (!ui_menu_scroll_test(block, my)) {
WM_event_timer_remove(CTX_wm_manager(C), win, menu->scrolltimer);
menu->scrolltimer = nullptr;
}
else {
ui_menu_scroll_to_y(region, block, my);
}
}
}
else {

View file

@ -340,7 +340,12 @@ Button *button_find_mouse_over_ex(const ARegion *region,
for (Block &block : region->runtime->uiblocks) {
float mx = xy[0], my = xy[1];
window_to_block_fl(region, &block, &mx, &my);
/* Skip when the mouse is hovering auto-scroll handlers. */
if ((block.flag & BLOCK_CLIPTOP && block.rect.ymax - UI_MENU_SCROLL_MOUSE < my) ||
(block.flag & BLOCK_CLIPBOTTOM && block.rect.ymin + UI_MENU_SCROLL_MOUSE > my))
{
continue;
}
for (int i = block.buttons.size() - 1; i >= 0; i--) {
Button *but = block.buttons[i].get();
if (find_poll && find_poll(but, find_custom_data) == false) {