diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-11 03:41:41 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-11 03:41:41 +0400 |
commit | 00014949c8a2e77e29d7ad690e20630dc4ebd1af (patch) | |
tree | f322549979e42589130039900317559416fe6600 /source/blender/editors | |
parent | 4ae201e105410df8df27bbe68bf7abc6ac3e49a0 (diff) |
Fix #35262: assiging shortcuts from e.g. delete or selection mode menus did not
work anymore. This was due to a bugfix to show missing shortcut keys for e.g. the
mesh > vertices > separate menu. Both should work now.
Diffstat (limited to 'source/blender/editors')
5 files changed, 25 insertions, 12 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 77bdd85d9fb..a97f1689db9 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -892,7 +892,7 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value void uiItemS(uiLayout *layout); /* separator */ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg); -void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon); +void uiItemMenuEnumO(uiLayout *layout, struct bContext *C, const char *opname, const char *propname, const char *name, int icon); void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon); /* UI Operators */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index d5c359d022e..87281ab7819 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -878,7 +878,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if (but->optype) { IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, + if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, true, buf, sizeof(buf))) { ui_but_add_shortcut(but, buf, FALSE); @@ -895,7 +895,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname)); - if (WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, + if (WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, buf, sizeof(buf))) { ui_but_add_shortcut(but, buf, FALSE); @@ -4093,7 +4093,7 @@ void uiButGetStrInfo(bContext *C, uiBut *but, ...) IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; char buf[512]; - if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, + if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, true, buf, sizeof(buf))) { tmp = BLI_strdup(buf); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 2bde6aa607f..0813e4cba07 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1681,10 +1681,11 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo uiItemsEnumO(layout, lvl->opname, lvl->propname); } -void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon) +void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name, int icon) { wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ MenuItemLevel *lvl; + char namestr[UI_MAX_NAME_STR], keybuf[128]; UI_OPERATOR_ERROR_RET(ot, opname, return ); @@ -1694,8 +1695,11 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, return; } - if (!name) - name = RNA_struct_ui_name(ot->srna); + if (name) + BLI_strncpy(namestr, name, sizeof(namestr)); + else + BLI_strncpy(namestr, RNA_struct_ui_name(ot->srna), sizeof(namestr)); + if (layout->root->type == UI_LAYOUT_MENU && !icon) icon = ICON_BLANK1; @@ -1704,7 +1708,16 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname)); lvl->opcontext = layout->root->opcontext; - ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, RNA_struct_ui_description(ot->srna)); + /* add hotkey here, lower UI code can't detect it */ + if(layout->root->block->flag & UI_BLOCK_LOOP) { + if (ot->prop && WM_key_event_operator_string(C, ot->idname, + layout->root->opcontext, NULL, false, keybuf, sizeof(keybuf))) { + strncat(namestr, "|", sizeof(namestr)-1); + strncat(namestr, keybuf, sizeof(namestr)-1); + } + } + + ui_item_menu(layout, namestr, icon, menu_item_enum_opname_menu, NULL, lvl, RNA_struct_ui_description(ot->srna)); } static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void *arg) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 38b8cd9312c..b87c067a1ab 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2768,7 +2768,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char /* check for hotkey */ if (len < sizeof(name) - 6) { - if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, + if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, true, &name[len + 1], sizeof(name) - len - 1)) { name[len] = '|'; diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 578006115a5..ce8ee25eef0 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -2329,7 +2329,7 @@ void logic_buttons(bContext *C, ARegion *ar) RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); uiLayoutSetContextPointer(row, "object", &object_ptr); - uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", IFACE_("Add Controller"), ICON_NONE); + uiItemMenuEnumO(row, C, "LOGIC_OT_controller_add", "type", IFACE_("Add Controller"), ICON_NONE); if (RNA_boolean_get(&settings_ptr, "show_state_panel")) { @@ -2426,7 +2426,7 @@ void logic_buttons(bContext *C, ARegion *ar) RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); uiLayoutSetContextPointer(row, "object", &object_ptr); - uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", IFACE_("Add Sensor"), ICON_NONE); + uiItemMenuEnumO(row, C, "LOGIC_OT_sensor_add", "type", IFACE_("Add Sensor"), ICON_NONE); if ((ob->scaflag & OB_SHOWSENS) == 0) continue; @@ -2497,7 +2497,7 @@ void logic_buttons(bContext *C, ARegion *ar) RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); uiLayoutSetContextPointer(row, "object", &object_ptr); - uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", IFACE_("Add Actuator"), ICON_NONE); + uiItemMenuEnumO(row, C, "LOGIC_OT_actuator_add", "type", IFACE_("Add Actuator"), ICON_NONE); if ((ob->scaflag & OB_SHOWACT) == 0) continue; |