From c276ef6a268bab16972021a3aaffe81b8689be84 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 10 Sep 2012 10:50:08 +0000 Subject: change to auto-opening menus so the first menu item in popup menu wont auto open. This way we can do predictable key-shortcut-chaining. Eg. Shift+A, M, O --- adds a metaball cone. In editmode Ctrl+V, X, A --- Assign new vertex group. --- source/blender/editors/interface/interface_handlers.c | 9 ++++++++- source/blender/editors/interface/interface_intern.h | 12 +++++++++++- source/blender/editors/interface/interface_regions.c | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 53cd7f3fb58..17486edd07f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5227,7 +5227,12 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s /* automatic open pulldown block timer */ if (ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) { - if (data->used_mouse && !data->autoopentimer) { + if ((data->used_mouse == TRUE) && + (data->autoopentimer == FALSE) && + /* don't popup the first time, + * see description on this member for info */ + (but->block->auto_is_first_event == FALSE)) + { int time; if (but->block->auto_open == TRUE) { /* test for toolbox */ @@ -5247,6 +5252,8 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s data->autoopentimer = WM_event_add_timer(data->wm, data->window, TIMER, 0.02 * (double)time); } } + + but->block->auto_is_first_event = FALSE; } } else { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index d308f7d852e..a5e4fa5890f 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -305,7 +305,17 @@ struct uiBlock { char direction; char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied to buttons */ char auto_open; - char _pad[7]; + + /* this setting is used so newly opened menu's dont popout the first item under the mouse, + * the reasoning behind this is because of muscle memory for opening menus. + * + * Without this, the first time opening a Submenu and activating an item in it will be 2 steps, + * but the second time the same item is accessed the menu memory would auto activate the + * last used menu and the key intended to select that submenu ends up being passed into the submenu. + * - Campbell + */ + char auto_is_first_event; + char _pad[6]; double auto_open_last; const char *lockstr; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 9c22b06fc1c..bebc80cbfc3 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2502,6 +2502,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->block->flag |= UI_BLOCK_POPUP_MEMORY; pup->block->puphash = ui_popup_menu_hash(title); + pup->block->auto_is_first_event = TRUE; pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN); -- cgit v1.2.3