diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-28 15:24:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-28 15:26:32 +0300 |
commit | 43248164a43fcb7e383854da5afc8b1637b54969 (patch) | |
tree | 815bb4206e4c73063a2e96ec4bf58ebc8020279c /source | |
parent | edbf15d3c044e719749b4874275c72b42838b00f (diff) |
PyAPI: add KeyMapItem.to_string() method
Useful for generating dynamic tooltips that include shortcuts.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index ef8607018d7..95c7d1cadf4 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -41,6 +41,8 @@ #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" +#include "UI_interface.h" + #include "wm_cursors.h" #include "rna_internal.h" /* own include */ @@ -73,6 +75,11 @@ const EnumPropertyItem rna_enum_window_cursor_items[] = { #include "WM_types.h" +static void rna_KeyMapItem_to_string(wmKeyMapItem *kmi, bool compact, char *result) +{ + WM_keymap_item_to_string(kmi, compact, result, UI_MAX_SHORTCUT_STR); +} + static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); @@ -830,6 +837,12 @@ void RNA_api_keymapitem(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_boolean(func, "result", 0, "Comparison result", ""); RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "to_string", "rna_KeyMapItem_to_string"); + RNA_def_boolean(func, "compact", false, "Compact", ""); + parm = RNA_def_string(func, "result", NULL, UI_MAX_SHORTCUT_STR, "result", ""); + RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); + RNA_def_function_output(func, parm); } void RNA_api_keymapitems(StructRNA *srna) |