[Bf-blender-cvs] [f1bc9331b15] master: Fix T55491: Double click fail in menu popups

Campbell Barton noreply at git.blender.org
Thu Jun 21 10:33:00 CEST 2018


Commit: f1bc9331b152cbe23d54dd01dc83871d07055477
Author: Campbell Barton
Date:   Thu Jun 21 09:50:24 2018 +0200
Branches: master
https://developer.blender.org/rBf1bc9331b152cbe23d54dd01dc83871d07055477

Fix T55491: Double click fail in menu popups

===================================================================

M	source/blender/editors/interface/interface_handlers.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 536327c465b..48d9e186863 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -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;
 }



More information about the Bf-blender-cvs mailing list