Node Wrangler: do not rely on image name to detect Viewer Node image
[blender-addons.git] / pose_library / keymaps.py
blob4541d988b29bca3abad547ca9c521e09c571b0d5
1 # SPDX-FileCopyrightText: 2010-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 from typing import List, Tuple
7 import bpy
9 addon_keymaps: List[Tuple[bpy.types.KeyMap, bpy.types.KeyMapItem]] = []
12 def register() -> None:
13 wm = bpy.context.window_manager
14 if wm.keyconfigs.addon is None:
15 # This happens when Blender is running in the background.
16 return
18 km = wm.keyconfigs.addon.keymaps.new(name="File Browser Main", space_type="FILE_BROWSER")
20 # DblClick to apply pose.
21 kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "DOUBLE_CLICK")
22 addon_keymaps.append((km, kmi))
24 # Asset Shelf
25 km = wm.keyconfigs.addon.keymaps.new(name="Asset Shelf")
26 # Click to apply pose.
27 kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "CLICK")
28 addon_keymaps.append((km, kmi))
29 # Drag to blend pose.
30 kmi = km.keymap_items.new("poselib.blend_pose_asset", "LEFTMOUSE", "CLICK_DRAG")
31 addon_keymaps.append((km, kmi))
34 def unregister() -> None:
35 # Clear shortcuts from the keymap.
36 for km, kmi in addon_keymaps:
37 km.keymap_items.remove(kmi)
38 addon_keymaps.clear()