Fix T55491: Double click fail in menu popups

This commit is contained in:
Campbell Barton 2018-06-21 09:50:24 +02:00
parent 3995b33a42
commit f1bc9331b1
Notes: blender-bot 2023-02-14 08:42:54 +01:00
Referenced by issue #55491, Double click fails with checkboxes in popovers
1 changed files with 24 additions and 7 deletions

View File

@ -9631,6 +9631,11 @@ static int ui_handle_menu_event(
retval = ui_handle_menu_button(C, event, menu);
}
/* Don't handle double click events, rehandle as regular press/release. */
if (retval == WM_UI_HANDLER_CONTINUE && event->val == KM_DBL_CLICK) {
return retval;
}
/* if we set a menu return value, ensure we continue passing this on to
* lower menus and buttons, so always set continue then, and if we are
* inside the region otherwise, ensure we swallow the event */
@ -10211,6 +10216,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
{
ARegion *ar;
uiBut *but;
int retval = WM_UI_HANDLER_CONTINUE;
ar = CTX_wm_menu(C);
if (!ar)
@ -10254,29 +10260,32 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
if ((but_other->flag & UI_BUT_DISABLED) == 0) {
ui_handle_button_activate(C, ar, but_other, BUTTON_ACTIVATE_OVER);
button_activate_state(C, but_other, BUTTON_STATE_MENU_OPEN);
retval = WM_UI_HANDLER_BREAK;
}
}
else if (data->state == BUTTON_STATE_MENU_OPEN) {
int retval;
/* handle events for menus and their buttons recursively,
* this will handle events from the top to the bottom menu */
if (data->menu)
if (data->menu) {
retval = ui_handle_menus_recursive(C, event, data->menu, 0, false, false, false);
}
/* handle events for the activated button */
if ((data->menu && (retval == WM_UI_HANDLER_CONTINUE)) ||
(event->type == TIMER))
{
if (data->menu && data->menu->menuretval)
if (data->menu && data->menu->menuretval) {
ui_handle_button_return_submenu(C, event, but);
else
ui_handle_button_event(C, event, but);
retval = WM_UI_HANDLER_BREAK;
}
else {
retval = ui_handle_button_event(C, event, but);
}
}
}
else {
/* handle events for the activated button */
ui_handle_button_event(C, event, but);
retval = ui_handle_button_event(C, event, but);
}
}
@ -10287,6 +10296,14 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
/* delayed apply callbacks */
ui_apply_but_funcs_after(C);
/* Don't handle double-click events,
* these will be converted into regular clicks which we handle. */
if (retval == WM_UI_HANDLER_CONTINUE) {
if (event->val == KM_DBL_CLICK) {
return WM_UI_HANDLER_CONTINUE;
}
}
/* we block all events, this is modal interaction */
return WM_UI_HANDLER_BREAK;
}