[Bf-blender-cvs] [c1f5ccb11a4] blender2.8: Keymap: allow filling in existing key-configs
Campbell Barton
noreply at git.blender.org
Fri Nov 16 06:01:57 CET 2018
Commit: c1f5ccb11a4e685be07f6bad993b4fcefe6b2ed4
Author: Campbell Barton
Date: Fri Nov 16 15:59:44 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBc1f5ccb11a4e685be07f6bad993b4fcefe6b2ed4
Keymap: allow filling in existing key-configs
Needed so we can get the preferences of a key-config
which are sent to a function that generates the contents.
===================================================================
M release/scripts/modules/bpy_extras/keyconfig_utils.py
===================================================================
diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py
index 6de0cc2e205..4d5ec5286ec 100644
--- a/release/scripts/modules/bpy_extras/keyconfig_utils.py
+++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py
@@ -488,6 +488,15 @@ def keymap_items_from_data(km, km_items, is_modal=False):
_kmi_props_setattr(kmi_props, attr, value)
+def keyconfig_init_from_data(kc, keyconfig_data):
+ # Load data in the format defined above.
+ #
+ # Runs at load time, keep this fast!
+ for (km_name, km_args, km_content) in keyconfig_data:
+ km = kc.keymaps.new(km_name, **km_args)
+ keymap_items_from_data(km, km_content["items"], is_modal=km_args.get("modal", False))
+
+
def keyconfig_import_from_data(name, keyconfig_data):
# Load data in the format defined above.
#
@@ -496,10 +505,7 @@ def keyconfig_import_from_data(name, keyconfig_data):
import bpy
wm = bpy.context.window_manager
kc = wm.keyconfigs.new(name)
- for (km_name, km_args, km_content) in keyconfig_data:
- km = kc.keymaps.new(km_name, **km_args)
- keymap_items_from_data(km, km_content["items"], is_modal=km_args.get("modal", False))
-
+ keyconfig_init_from_data(kc, keyconfig_data)
return kc
More information about the Bf-blender-cvs
mailing list