Merge pull request #10377 from dotCooCoo/fix/tool-shortcut-collisions

Shortcuts: a lone Alt over the canvas no longer gives the menu bar the keys
This commit is contained in:
.CooCoo authored and GitHub committed 2026-12-01 01:51:18 -08:00
commit 69b1f26ff0
2 files changed
+22 -3

No files matched your search

+8 -1
View File
@@ -463,7 +463,14 @@ impl CanvasTool for SessionTool<'_> {
if claim(&mut app, EngineKey::Left) {
claims = claims.nudges();
}
if claim(&mut app, EngineKey::AltTap) {
// A lone Alt while the canvas has the keys is the tools' modifier let go without a click: the canvas takes it,
// so it does not give the menu bar the keys and the next tool letter still chooses its tool. F10 and Alt with
// a letter still reach the bar, and a lone Alt in a field or the bar keeps the framework's rule.
let canvas_has_keys = app
.ui_ctx
.as_ref()
.is_some_and(|ctx| !ctx.egui_wants_keyboard_input() && !craft::ui::menu::bar::is_focused(ctx) && !craft::ui::menu::bar::is_open(ctx));
if canvas_has_keys || claim(&mut app, EngineKey::AltTap) {
claims = claims.alt_tap();
}
claims
+14 -2
View File
@@ -164,10 +164,22 @@ fn menu_access_custom_shortcut_typing_tool_altgr_and_cancel_ownership() {
assert_eq!(s.app.session.tool_id(), "pen", "after the dismissal the letter selects its tool");
s.app.select_tool("selection");
// While the bar holds the keys after a lone Alt, the letter does not reach the tool either.
// A lone Alt over the canvas is a tool modifier let go: the bar does not take the keys, and the next tool
// letters choose their tools instead of opening View or Window.
s.bare_alt();
s.settle();
assert!(is_focused(&s.ctx), "a lone Alt gives the bar the keys");
assert!(!is_focused(&s.ctx) && !is_open(&s.ctx), "a lone Alt over the canvas leaves the bar alone");
s.letter(Key::V, "v", Modifiers::NONE);
assert!(!is_open(&s.ctx), "V after a lone Alt opens no menu");
s.letter(Key::P, "p", Modifiers::NONE);
assert_eq!(s.app.session.tool_id(), "pen", "P after a lone Alt chooses the Pen");
s.app.select_tool("selection");
// While the bar holds the keys after F10, the letter does not reach the tool.
s.frame(vec![key(Key::F10, true, Modifiers::NONE)]);
s.frame(vec![key(Key::F10, false, Modifiers::NONE)]);
s.settle();
assert!(is_focused(&s.ctx), "F10 gives the bar the keys");
s.letter(Key::P, "p", Modifiers::NONE);
assert_eq!(s.app.session.tool_id(), "selection", "a focused bar takes the letter");
s.click(outside);