[Bf-blender-cvs] [3b7daa5bf46] blender2.8: Tool System: Updates for keymap stored as string

Campbell Barton noreply at git.blender.org
Thu Nov 22 01:14:24 CET 2018


Commit: 3b7daa5bf46598267844a3fcf60109b69c5dae1f
Author: Campbell Barton
Date:   Thu Nov 22 11:13:22 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB3b7daa5bf46598267844a3fcf60109b69c5dae1f

Tool System: Updates for keymap stored as string

===================================================================

M	release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
M	release/scripts/startup/bl_ui/space_toolsystem_common.py

===================================================================

diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
index b5dcb123120..183f13b92fb 100644
--- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
+++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
@@ -197,17 +197,23 @@ def generate(context, space_type):
                     context='INVOKE_REGION_WIN',
                 )[1]
             elif item.keymap is not None:
-                kmi_first = item.keymap[0].keymap_items
-                kmi_first = kmi_first[0] if kmi_first else None
-                if kmi_first is not None:
-                    kmi_found = wm.keyconfigs.find_item_from_operator(
-                        idname=kmi_first.idname,
-                        # properties=kmi_first.properties,  # prevents matches, don't use.
-                        context='INVOKE_REGION_WIN',
-                    )[1]
-                else:
+                km = keyconf.keymaps.get(item.keymap[0])
+                if km is None:
+                    print("Keymap", repr(item.keymap[0]), "not found for tool", item.text)
                     kmi_found = None
-                del kmi_first
+                else:
+                    kmi_first = km.keymap_items
+                    kmi_first = kmi_first[0] if kmi_first else None
+                    if kmi_first is not None:
+                        kmi_found = wm.keyconfigs.find_item_from_operator(
+                            idname=kmi_first.idname,
+                            # properties=kmi_first.properties,  # prevents matches, don't use.
+                            context='INVOKE_REGION_WIN',
+                        )[1]
+                    else:
+                        kmi_found = None
+                    del kmi_first
+                del km
             else:
                 kmi_found = None
             item_container[1] = kmi_found
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 09a1d961e24..2ff5c9692ec 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -687,8 +687,14 @@ def description_from_name(context, space_type, text, *, use_operator=True):
 
         if operator is None:
             if item.keymap is not None:
-                if item.keymap[0].keymap_items:
-                    operator = item.keymap[0].keymap_items[0].idname
+                wm = context.window_manager
+                keyconf = wm.keyconfigs.active
+                km = keyconf.keymaps.get(item.keymap[0])
+                if km is not None:
+                    for kmi in km.keymap_items:
+                        if kmi.active:
+                            operator = kmi.idname
+                            break
 
         if operator is not None:
             import _bpy



More information about the Bf-blender-cvs mailing list