[Bf-blender-cvs] [5a1a633d043] master: UI: minor change to active-default logic

Campbell Barton noreply at git.blender.org
Wed Mar 27 15:00:36 CET 2019


Commit: 5a1a633d0435531c2dabf3442e2a3ca72b4a6da3
Author: Campbell Barton
Date:   Thu Mar 28 00:57:46 2019 +1100
Branches: master
https://developer.blender.org/rB5a1a633d0435531c2dabf3442e2a3ca72b4a6da3

UI: minor change to active-default logic

Don't attempt to activate default button if it's already active.

Also expand on the flags comment.

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_handlers.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index ec88278ec88..9f189b63ad5 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -193,7 +193,9 @@ enum {
 	UI_BUT_IMMEDIATE       = 1 << 20,
 	UI_BUT_NO_UTF8         = 1 << 21,
 
-	/** For popups, pressing return activates this button, overriding the highlighed button. */
+	/** For popups, pressing return activates this button, overriding the highlighted button.
+	 * For non-popups this is just used as a display hint for the user to let them
+	 * know the action which is activated when pressing return (file selector for eg). */
 	UI_BUT_ACTIVE_DEFAULT = 1 << 23,
 
 	/** This but is "inside" a list item (currently used to change theme colors). */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c388ed40851..800b15bff61 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -9242,7 +9242,7 @@ static int ui_handle_menu_event(
 			}
 			else if (ELEM(event->type, RETKEY, PADENTER) && event->val == KM_PRESS) {
 				uiBut *but_active = ui_region_find_first_but_test_flag(ar, UI_BUT_ACTIVE_DEFAULT, UI_HIDDEN);
-				if (but_active != NULL) {
+				if ((but_active != NULL) && (but_active->active == NULL)) {
 					ui_handle_button_activate(C, ar, but_active, BUTTON_ACTIVATE);
 					/* Get again below just incase it's disabled for eg. */
 				}



More information about the Bf-blender-cvs mailing list