From 16d7fca162ac46f5f890b751e2e923b53c620e64 Mon Sep 17 00:00:00 2001 From: tareq Date: Fri, 30 Oct 2026 12:44:01 +0100 Subject: [PATCH] Tools bar: ignore create-on-double-click after an Alt-click. egui pairs a plain click with a prior Alt-click as a double-click; remember the previous click's Alt so create-on-double-click only runs for two plain clicks. --- crates/ui-egui/src/header.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/header.rs b/crates/ui-egui/src/header.rs index 9fa98f9ac..3d443bdca 100644 --- a/crates/ui-egui/src/header.rs +++ b/crates/ui-egui/src/header.rs @@ -105,7 +105,12 @@ fn tool_slot(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter, si: // Plain click selects the shown tool; Alt/Option-click cycles the flyout slot // (After Effects / Photoshop parity with the Shift+letter key cycle). let alt = ui.input(|i| i.modifiers.alt); - if resp.clicked() && !held { + // egui's double-click ignores modifiers: remember the previous click's Alt so + // create-on-double-click only runs for two plain clicks (same as PhotoCraft). + let prev_alt_id = id.with("click-alt"); + let prev_alt = ui.data(|d| d.get_temp::(prev_alt_id)).unwrap_or(false); + let slot_click = resp.clicked() && !held; + if slot_click { let pick = if slot.len() > 1 && alt { let from = if slot.contains(&app.ui.tool) { app.ui.tool } else { cur }; let i = slot.iter().position(|t| *t == from).unwrap_or(0); @@ -127,11 +132,15 @@ fn tool_slot(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter, si: app.ui.status = e; } else if resp.double_clicked() && !alt + && !prev_alt && let Some((id, params)) = create_on_double_click(app, cur) && let Err(e) = crate::menus::invoke(app, ui.ctx(), id, params) { app.ui.status = e; } + if slot_click { + ui.data_mut(|d| d.insert_temp(prev_alt_id, alt)); + } if slot.len() > 1 { slot_flyout(app, ui, si, slot, &resp, held_id); }