From 14bac995f38251f4a6b7b210ef968dc5311580e8 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 27 Sep 2015 09:49:41 +0200 Subject: Fix T46268: All Hotkey "C" are unexpectedly translated in menus. We need custom context here, those are often very short names so context collision is pretty easy. Also some minor changes (and avoid shadowing varnames)... --- source/blender/windowmanager/intern/wm_keymap.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 5098df2c0a6..016583e69a5 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -903,15 +903,21 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km) const char *WM_key_event_string(const short type, const bool compact) { - const char *name = NULL; + EnumPropertyItem *it; + const int i = RNA_enum_from_value(event_type_items, (int)type); + + if (i == -1) { + return ""; + } + it = &event_type_items[i]; + /* We first try enum items' description (abused as shortname here), and fall back to usual name if empty. */ - if ((compact && RNA_enum_description(event_type_items, (int)type, &name) && name[0]) || - RNA_enum_name(event_type_items, (int)type, &name)) - { - return IFACE_(name); + if (compact && it->description[0]) { + /* XXX No context for enum descriptions... In practice shall not be an issue though. */ + return IFACE_(it->description); } - return ""; + return CTX_IFACE_(BLT_I18NCONTEXT_UI_EVENTS, it->name); } /* TODO: also support (some) value, like e.g. double-click? */ -- cgit v1.2.3