Fix generated toolbar keymap w/ annotation tool
authorCampbell Barton <ideasman42@gmail.com>
Mon, 7 Jan 2019 00:00:46 +0000 (11:00 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 7 Jan 2019 00:00:46 +0000 (11:00 +1100)
release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py

index ba76842..c490561 100644 (file)
@@ -230,12 +230,19 @@ def generate(context, space_type):
                 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',
-                        include={'KEYBOARD'},
-                    )[1]
+                    # We need 'MOUSE' so keys with 'key_modifier' are found.
+                    for kmi_type in ('KEYBOARD', 'MOUSE'):
+                        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',
+                            include={kmi_type},
+                        )[1]
+                        if kmi_found is not None:
+                            if (kmi_type == 'MOUSE') and (kmi_found.key_modifier == 'NONE'):
+                                kmi_found = None
+                        if kmi_found is not None:
+                            break
                 else:
                     kmi_found = None
                 del kmi_first