345cd70404
This has been mentioned as a bug in the recent A&R module meeting https://devtalk.blender.org/t/2024-05-14-animation-rigging-module-meeting/34614#ux-quirks-in-the-pose-library-shelf-5 Pressing `Ctrl` only worked from within the modal operator, but not to start it. The issue was that the entry for that was missing from the keymap. This PR adds a keymap entry to apply and to blend a pose flipped, by holding `Ctrl` first and then clicking the pose asset. Pull Request: https://projects.blender.org/blender/blender/pulls/121860
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
# SPDX-FileCopyrightText: 2010-2023 Blender Foundation
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
from typing import List, Tuple
|
|
|
|
import bpy
|
|
|
|
addon_keymaps: List[Tuple[bpy.types.KeyMap, bpy.types.KeyMapItem]] = []
|
|
|
|
|
|
def register() -> None:
|
|
wm = bpy.context.window_manager
|
|
if wm.keyconfigs.addon is None:
|
|
# This happens when Blender is running in the background.
|
|
return
|
|
|
|
km = wm.keyconfigs.addon.keymaps.new(name="File Browser Main", space_type="FILE_BROWSER")
|
|
|
|
# DblClick to apply pose.
|
|
kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "DOUBLE_CLICK")
|
|
addon_keymaps.append((km, kmi))
|
|
|
|
# Asset Shelf
|
|
km = wm.keyconfigs.addon.keymaps.new(name="Asset Shelf")
|
|
# Click to apply pose.
|
|
kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "CLICK")
|
|
addon_keymaps.append((km, kmi))
|
|
kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "CLICK", ctrl=True)
|
|
kmi.properties.flipped = True
|
|
addon_keymaps.append((km, kmi))
|
|
# Drag to blend pose.
|
|
kmi = km.keymap_items.new("poselib.blend_pose_asset", "LEFTMOUSE", "CLICK_DRAG")
|
|
addon_keymaps.append((km, kmi))
|
|
kmi = km.keymap_items.new("poselib.blend_pose_asset", "LEFTMOUSE", "CLICK_DRAG", ctrl=True)
|
|
kmi.properties.flipped = True
|
|
addon_keymaps.append((km, kmi))
|
|
|
|
|
|
def unregister() -> None:
|
|
# Clear shortcuts from the keymap.
|
|
for km, kmi in addon_keymaps:
|
|
km.keymap_items.remove(kmi)
|
|
addon_keymaps.clear()
|