From 27f29cdfba889ffb07689a28a949de47b9392666 Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 24 Mar 2020 21:25:52 +0100 Subject: [PATCH] Fix T74038 : Scrolling doesn't work in menu if there is no active item Fix T74038, the logic didn't handle the case where there was not any button with focus. Reviewed By: Julian Eisel Maniphest Tasks: T74038 Differential Revision: https://developer.blender.org/D7208 --- .../editors/interface/interface_handlers.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 2dfa29f5646..07d5dd6e544 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -9694,15 +9694,9 @@ static int ui_handle_menu_event(bContext *C, /* Apply scroll operation. */ if (scrolltype == MENU_SCROLL_DOWN) { but = ui_but_next(but); - if (but == NULL) { - but = ui_but_first(block); - } } else if (scrolltype == MENU_SCROLL_UP) { but = ui_but_prev(but); - if (but == NULL) { - but = ui_but_last(block); - } } else if (scrolltype == MENU_SCROLL_TOP) { but = ui_but_first(block); @@ -9712,6 +9706,20 @@ static int ui_handle_menu_event(bContext *C, } } + if (!but) { + /* wrap button or no active button*/ + uiBut *but_wrap = NULL; + if (ELEM(scrolltype, MENU_SCROLL_UP, MENU_SCROLL_BOTTOM)) { + but_wrap = ui_but_last(block); + } + else if (ELEM(scrolltype, MENU_SCROLL_DOWN, MENU_SCROLL_TOP)) { + but_wrap = ui_but_first(block); + } + if (but_wrap) { + but = but_wrap; + } + } + if (but) { ui_handle_button_activate(C, region, but, BUTTON_ACTIVATE); ui_menu_scroll_to_but(region, block, but);