From 42f8b495815c95211ebd969283ea2bf47fa7c720 Mon Sep 17 00:00:00 2001 From: Leon Schittek Date: Fri, 15 Sep 2023 19:33:20 +0200 Subject: [PATCH] Fix: Show modal keymap for operators called inside macros Display the modal keymap in the status bar for modal operators that are called within macros. Most notably, the keymap for the transform operator is displayed when it's called as part of the duplicate, extrude, or loopcut operators or when moving nodes. Pull Request: https://projects.blender.org/blender/blender/pulls/108027 --- .../transform/transform_mode_translate.cc | 18 +----------------- .../windowmanager/intern/wm_event_system.cc | 5 +++-- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/source/blender/editors/transform/transform_mode_translate.cc b/source/blender/editors/transform/transform_mode_translate.cc index 44cbebe7bda..c9deb98579a 100644 --- a/source/blender/editors/transform/transform_mode_translate.cc +++ b/source/blender/editors/transform/transform_mode_translate.cc @@ -303,24 +303,8 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ const char *str_dir = (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_RIGHT) ? TIP_("right") : TIP_("left"); - char str_dir_km[64]; - WM_modalkeymap_items_to_string( - t->keymap, TFM_MODAL_INSERTOFS_TOGGLE_DIR, true, str_dir_km, sizeof(str_dir_km)); - ofs += BLI_snprintf_rlen(str, - UI_MAX_DRAW_STR, - TIP_("%s: Toggle auto-offset direction (%s)"), - str_dir_km, - str_dir); + ofs += BLI_snprintf_rlen(str, UI_MAX_DRAW_STR, TIP_("Auto-offset direction: %s"), str_dir); } - - char str_attach_km[64]; - WM_modalkeymap_items_to_string( - t->keymap, TFM_MODAL_NODE_ATTACH_OFF, true, str_attach_km, sizeof(str_attach_km)); - ofs += BLI_snprintf_rlen(str + ofs, - UI_MAX_DRAW_STR - ofs, - TIP_(", %s: Toggle auto-attach (%s)"), - str_attach_km, - WM_bool_as_string((t->modifiers & MOD_NODE_ATTACH) != 0)); } else { if (t->flag & T_2D_EDIT) { diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 4ecb715a260..d06290cfa9c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -6277,10 +6277,11 @@ bool WM_window_modal_keymap_status_draw(bContext *C, wmWindow *win, uiLayout *la wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base; if (handler->op != nullptr) { /* 'handler->keymap' could be checked too, seems not to be used. */ - wmKeyMap *keymap_test = WM_keymap_active(wm, handler->op->type->modalkeymap); + wmOperator *op_test = handler->op->opm ? handler->op->opm : handler->op; + wmKeyMap *keymap_test = WM_keymap_active(wm, op_test->type->modalkeymap); if (keymap_test && keymap_test->modal_items) { keymap = keymap_test; - op = handler->op; + op = op_test; break; } }