diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-13 10:34:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-13 10:34:22 +0300 |
commit | e1772dac7065c92859a1db40ccb569b570b0159a (patch) | |
tree | 11ad1639ae8989d8371fe603e8ddd4bbfacc493c /source | |
parent | cee39da318f23904e334cc98cdd1e6fb100297d6 (diff) |
WM: utility to create tool keybindings
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/WM_keymap.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index b4d4d55479d..a34862caf0d 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -66,6 +66,8 @@ wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, in int val, int modifier, int keymodifier); wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); +wmKeyMapItem *WM_keymap_add_tool(struct wmKeyMap *keymap, const char *idname, int type, + int val, int modifier, int keymodifier); bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); int WM_keymap_item_to_string(wmKeyMapItem *kmi, const bool compact, char *result, const int result_len); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 27b9710cb45..63f81ca66c9 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -508,6 +508,14 @@ wmKeyMapItem *WM_keymap_add_menu_pie(wmKeyMap *keymap, const char *idname, int t return kmi; } +/* tool wrapper for WM_keymap_add_item */ +wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) +{ + wmKeyMapItem *kmi = WM_keymap_add_item(keymap, "WM_OT_tool_set_by_name", type, val, modifier, keymodifier); + RNA_string_set(kmi->ptr, "name", idname); + return kmi; +} + bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) { if (BLI_findindex(&keymap->items, kmi) != -1) { |