From add48983ca6965c1da7ac7bdd0f4100c04a7a4ce Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 20 Oct 2012 14:13:14 +0000 Subject: [PATCH] Bugfix #32641 User preferences, keymap editor: it allowed to set any event for "key modifier", and not even to NULL the option. Now it limits to keyboard events, on mouseclicks it clears, on ESC it exits without changes. --- source/blender/makesrna/intern/rna_wm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 30bdc717f50..2462733915b 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -629,6 +629,20 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) } } +/* assumes value to be an enum from event_type_items */ +/* function makes sure keymodifiers are only valid keys, ESC keeps it unaltered */ +static void rna_wmKeyMapItem_keymodifier_set(PointerRNA *ptr, int value) +{ + wmKeyMapItem *kmi = ptr->data; + + if (value == ESCKEY); + else if (value >= AKEY) + kmi->keymodifier = value; + else + kmi->keymodifier = 0; +} + + static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *UNUSED(free)) { @@ -1865,6 +1879,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "keymodifier"); RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_wmKeyMapItem_keymodifier_set", NULL); RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier"); RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");