From d3e33d89a99799867ea35fed0af0d663f7386bbd Mon Sep 17 00:00:00 2001 From: mjohnson7cd <61306576+mjohnson7cd@users.noreply.github.com> Date: Tue, 13 Oct 2026 01:51:23 -0400 Subject: [PATCH] fix(ui): click and hold on a toolbar button selects its tool (#4453) (#4544) Co-authored-by: Brandon Thomas --- crates/ui-egui/src/panels.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index adcb86f710..1d3259a710 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -198,6 +198,8 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { }); } if slot.len() > 1 && long_press { + // Holding a tool button selects the tool it shows, as a click would (#4453). + app.ui.tool = tool; ui.ctx().request_repaint(); } if let Some((open_key, anchor)) = ui.data(|d| d.get_temp::<(egui::Id, Rect)>(flyout_id)) @@ -4707,9 +4709,9 @@ mod type_flyout_tests { } #[test] - fn long_press_type_button_selects_vertical_without_selecting_on_release() { + fn long_press_type_button_selects_type_then_vertical_from_the_flyout() { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); - let initial = app.ui.tool; + assert_ne!(app.ui.tool, Tool::Type); let ctx = egui::Context::default(); PhotocraftApp::setup_context(&ctx, crate::theme::ThemeKind::ALL[0]); frame(&mut app, &ctx, 0.0, vec![]); @@ -4733,7 +4735,8 @@ mod type_flyout_tests { assert_eq!(ctx.data(|d| d.get_temp::<(egui::Id, Rect)>(egui::Id::new("tool-flyout"))).map(|(id, _)| id), Some(egui::Id::new(("tool-slot", index)))); frame(&mut app, &ctx, 1.4, vec![pointer(at, false)]); frame(&mut app, &ctx, 1.45, vec![]); - assert_eq!(app.ui.tool, initial); + // The held button's tool is selected, as Photoshop does (#4453). + assert_eq!(app.ui.tool, Tool::Type); let key = egui::Id::new(("tool-slot", index)); let menu = ctx.memory(|m| m.area_rect(key.with("flyout"))).unwrap(); let row = egui::pos2(menu.left() + 65.0, menu.top() + 39.0 + 8.0);