From bfb4b233ef1c36203edb1d1bb07c08b84de9869f Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 10:42:22 +0700 Subject: [PATCH] An arrow bound to an app command runs it from the canvas tool adapter The window's document canvas keeps the arrows it takes, also with nothing focused (craft-libs ebc242fe3), so the keymap no longer runs a bound arrow beside the declined nudge. The adapter fires the command it finds. --- crates/ui-egui/src/canvas/tool_adapter.rs | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index 59e85aedeb..9ea52ed030 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -430,20 +430,29 @@ impl CanvasTool for SessionTool<'_> { if self.send_key(k, tool_mods(*mods, space)) || self.busy_key(k) { return true; } - // An arrow an application command is bound to runs it, as production's keymap ran it first; one it - // leaves moves the selection, with Backtick held only its pattern paint. A panel's own arrows (a page - // preview's) are not the canvas's. + // An arrow an application command is bound to runs it, as production's keymap ran it first: the + // canvas takes every arrow, so no shortcut runs it otherwise. One it leaves moves the selection, with + // Backtick held only its pattern paint. A panel's own arrows (a page preview's) are not the canvas's. let chord = Chord::new(*mods, arrow); - let bound = self.app().ui_ctx.as_ref().and_then(craft::ui::runtime::commands::keymap).is_some_and(|keymap| { + let ctx = self.app().ui_ctx.clone(); + let bound = ctx.as_ref().and_then(craft::ui::runtime::commands::keymap).and_then(|keymap| { let global = |command: &craft::keymap::CommandRef| { keymap.bindable(command).is_some_and(|def| keymap.scopes().kind(&def.scope) == craft::keymap::ScopeKind::Application) }; - !matches!(keymap.lookup_where(&chord, false, &craft::keymap::Active::NONE, &[], &global), craft::keymap::Lookup::None) + match keymap.lookup_where(&chord, false, &craft::keymap::Active::NONE, &[], &global) { + craft::keymap::Lookup::Run(command) => Some(command), + // The key's own press fires the group's first tool, as here. + craft::keymap::Lookup::Cycle(commands) => commands.into_iter().next(), + _ => None, + } }); - if !bound { - crate::shortcuts::nudge(&mut self.app(), *direction, *mods, with.contains(&Key::Backtick)); + match ctx.zip(bound) { + Some((ctx, command)) => { + craft::ui::runtime::commands::fire(&ctx, command, craft::ui::runtime::commands::FireSource::Key); + } + None => crate::shortcuts::nudge(&mut self.app(), *direction, *mods, with.contains(&Key::Backtick)), } - !bound + true } ToolKey::Delete { forward, .. } => self.send_key(if *forward { EngineKey::Delete } else { EngineKey::Backspace }, held), ToolKey::Submit => {