Fix #145388: Pose library breaks double-click in file browser
The pose library registered a double-click keymap item for the file
browser keymap, because that was the only way to add keymap items to the
asset browser (which is just the file browser under the hood). Since
450f428434, the pose library apply & blend operators are available in
more contexts, since their check for an active asset was moved from the
operator poll to the operator execution. So the pose apply operator
would end up triggering.
The poll function could be adjusted somehow to return false in this
case, e.g. by checking if it's executed from a file browser (not an
asset browser).
However, the operator should be independent of where it's called from.
So instead this registers a separate keymap for the asset browser, so
the pose library operators can be registered exclusively for the asset
browser.
This commit is contained in:
@@ -15,7 +15,7 @@ def register() -> 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")
|
||||
km = wm.keyconfigs.addon.keymaps.new(name="Asset Browser Main", space_type="FILE_BROWSER")
|
||||
|
||||
# DblClick to apply pose.
|
||||
kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "DOUBLE_CLICK")
|
||||
|
||||
@@ -450,6 +450,11 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *region)
|
||||
keymap = WM_keymap_ensure(
|
||||
wm->runtime->defaultconf, "File Browser Main", SPACE_FILE, RGN_TYPE_WINDOW);
|
||||
WM_event_add_keymap_handler_v2d_mask(®ion->runtime->handlers, keymap);
|
||||
|
||||
keymap = WM_keymap_ensure(
|
||||
wm->runtime->defaultconf, "Asset Browser Main", SPACE_FILE, RGN_TYPE_WINDOW);
|
||||
WM_event_add_keymap_handler_v2d_mask(®ion->runtime->handlers, keymap);
|
||||
keymap->poll = [](bContext *C) { return ED_operator_asset_browsing_active(C); };
|
||||
}
|
||||
|
||||
static void file_main_region_listener(const wmRegionListenerParams *listener_params)
|
||||
|
||||
@@ -489,7 +489,9 @@ bool WM_keymap_poll(bContext *C, wmKeyMap *keymap)
|
||||
!STREQ(keymap->idname, "Node Tool: Tweak") &&
|
||||
/* Another exception: Asset shelf keymap is meant for add-ons to use, it's empty by
|
||||
* default. */
|
||||
!STREQ(keymap->idname, "Asset Shelf"))
|
||||
!STREQ(keymap->idname, "Asset Shelf") &&
|
||||
/* Same for the asset browser keymap. */
|
||||
!STREQ(keymap->idname, "Asset Browser Main"))
|
||||
{
|
||||
CLOG_WARN(WM_LOG_EVENTS, "empty keymap '%s'", keymap->idname);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user