[Bf-blender-cvs] [e4694c057bc] master: UI: replace button open event with activate on init

Campbell Barton noreply at git.blender.org
Thu Mar 21 14:59:08 CET 2019


Commit: e4694c057bcc5200e8bd1e906dc1d687a4f3aca2
Author: Campbell Barton
Date:   Fri Mar 22 00:54:07 2019 +1100
Branches: master
https://developer.blender.org/rBe4694c057bcc5200e8bd1e906dc1d687a4f3aca2

UI: replace button open event with activate on init

No user visible change.

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

M	source/blender/editors/interface/interface_region_menu_popup.c
M	source/blender/editors/space_node/node_select.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index bd8f62e2abd..bda19b712a1 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -567,6 +567,7 @@ void UI_popup_block_invoke_ex(bContext *C, uiBlockCreateFunc func, void *arg, co
 	handle->opcontext = opcontext;
 
 	UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
+	UI_block_active_only_flagged_buttons(C, handle->region, handle->region->uiblocks.first);
 	WM_event_add_mousemove(C);
 }
 
@@ -594,6 +595,7 @@ void UI_popup_block_ex(
 	// handle->opcontext = opcontext;
 
 	UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
+	UI_block_active_only_flagged_buttons(C, handle->region, handle->region->uiblocks.first);
 	WM_event_add_mousemove(C);
 }
 
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index aed5c590bb4..fc80d20dcba 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -1070,8 +1070,6 @@ static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2
 static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
 {
 	static char search[256] = "";
-	wmEvent event;
-	wmWindow *win = CTX_wm_window(C);
 	uiBlock *block;
 	uiBut *but;
 	wmOperator *op = (wmOperator *)arg_op;
@@ -1082,6 +1080,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
 
 	but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, "");
 	UI_but_func_search_set(but, NULL, node_find_cb, op->type, false, node_find_call_cb, NULL);
+	UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
 
 	/* fake button, it holds space for search items */
 	uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL);
@@ -1089,14 +1088,6 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
 	/* Move it downwards, mouse over button. */
 	UI_block_bounds_set_popup(block, 6, (const int[2]){0, -UI_UNIT_Y});
 
-	//	UI_but_active_only(C, ar, block, but); XXX using this here makes Blender hang - investigate
-	wm_event_init_from_window(win, &event);
-	event.type = EVT_BUT_OPEN;
-	event.val = KM_PRESS;
-	event.customdata = but;
-	event.customdatafree = false;
-	wm_event_add(win, &event);
-
 	return block;
 }
 
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 979473cf761..3db5ff4d848 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1587,8 +1587,6 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *userdata)
 {
 	const struct SearchPopupInit_Data *init_data = userdata;
 	static char search[256] = "";
-	wmEvent event;
-	wmWindow *win = CTX_wm_window(C);
 	uiBlock *block;
 	uiBut *but;
 
@@ -1598,6 +1596,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *userdata)
 
 	but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, init_data->size[0], UI_UNIT_Y, 0, 0, "");
 	UI_but_func_operator_search(but);
+	UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
 
 	/* fake button, it holds space for search items */
 	uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - init_data->size[1],
@@ -1606,13 +1605,6 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *userdata)
 	/* Move it downwards, mouse over button. */
 	UI_block_bounds_set_popup(block, 6, (const int[2]){0, -UI_UNIT_Y});
 
-	wm_event_init_from_window(win, &event);
-	event.type = EVT_BUT_OPEN;
-	event.val = KM_PRESS;
-	event.customdata = but;
-	event.customdatafree = false;
-	wm_event_add(win, &event);
-
 	return block;
 }



More information about the Bf-blender-cvs mailing list