Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-01-09 04:26:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-09 04:26:10 +0300
commit34143a9e7ae0017bb4825d5f9e885a87da236159 (patch)
treef64b329db113d6b0cb157ed5fe75bfa2bc73c5ee /source/blender/makesrna/intern/rna_wm_api.c
parentd6152033420a7d5aed12c463b6d30fe957b12787 (diff)
WM: add keymap.find_from_operator(...)
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 51291f70cfa..9d93bcba508 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -309,6 +309,23 @@ static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA
RNA_POINTER_INVALIDATE(kmi_ptr);
}
+static PointerRNA rna_KeyMap_item_find_from_operator(
+ ID *id,
+ wmKeyMap *km,
+ const char *idname,
+ PointerRNA *properties,
+ int include_mask, int exclude_mask)
+{
+ char idname_bl[OP_MAX_TYPENAME];
+ WM_operator_bl_idname(idname_bl, idname);
+
+ wmKeyMapItem *kmi = WM_key_event_operator_from_keymap(
+ km, idname_bl, properties->data, include_mask, exclude_mask);
+ PointerRNA kmi_ptr;
+ RNA_pointer_create(id, &RNA_KeyMapItem, kmi, &kmi_ptr);
+ return kmi_ptr;
+}
+
static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, bool modal, bool tool)
{
wmKeyMap *keymap;
@@ -908,6 +925,20 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_property_ui_text(parm, "id", "ID of the item");
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
RNA_def_function_return(func, parm);
+
+ /* Keymap introspection
+ * Args follow: KeyConfigs.find_item_from_operator */
+ func = RNA_def_function(srna, "find_from_operator", "rna_KeyMap_item_find_from_operator");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
+ RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
+ RNA_def_enum_flag(func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
+ RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
+ parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
+ RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
+ RNA_def_function_return(func, parm);
}
void RNA_api_keymaps(StructRNA *srna)