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
This commit is contained in:
Leon Schittek 2023-09-15 19:33:20 +02:00 committed by Harley Acheson
parent e553c71aae
commit 42f8b49581
2 changed files with 4 additions and 19 deletions

View File

@ -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) {

View File

@ -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;
}
}