Skip to content
Snippets Groups Projects
Commit 8a62f77e authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Bone Selection Sets: better keymap handling

Previously the keymap registration would cause an error when there was
no Pose keymap yet. Now the code adheres to the example code in
[the tutorial](https://docs.blender.org/api/blender_python_api_master/info_tutorial_addon.html#keymap).
parent fad17c65
No related branches found
No related tags found
No related merge requests found
......@@ -514,6 +514,10 @@ def uniqify(name: str, other_names: list) -> str:
return "{}.{:03d}".format(name, min_index)
# store keymaps here to access after registration
addon_keymaps = []
def register():
for cls in classes:
bpy.utils.register_class(cls)
......@@ -530,10 +534,11 @@ def register():
)
wm = bpy.context.window_manager
km = wm.keyconfigs.active.keymaps['Pose']
km = wm.keyconfigs.addon.keymaps.new(name='Pose')
kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True, shift=True)
kmi.properties.name = 'POSE_MT_selection_sets'
addon_keymaps.append((km, kmi))
bpy.types.VIEW3D_MT_select_pose.append(add_sss_button)
......@@ -545,6 +550,11 @@ def unregister():
del bpy.types.Object.selection_sets
del bpy.types.Object.active_selection_set
# handle the keymap
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
if __name__ == "__main__":
import doctest
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment