From 699b5da7dc15e8f79341171f8953d72a8dec45d6 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 16 Oct 2026 04:37:18 +0000 Subject: [PATCH] Integration: #1076 the release that ends a hold opening a tool flyout doesn't pick the tool and close it --- crates/ui-egui/src/toolbar.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 7c8ddbd6..a04c45a4 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -99,9 +99,16 @@ pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) { Stroke::NONE, )); } - if resp.clicked() { + // The release that ends a hold which opened the flyout isn't a click + // on the tool (egui reports releases within 0.8 s as clicks). + let hold_id = egui::Id::new(("flyout_hold", gi)); + let ended_hold = resp.clicked() && ui.data_mut(|d| d.remove_temp::(hold_id)).unwrap_or(false); + if resp.clicked() && !ended_hold { chosen = Some(shown.id); } + if !resp.is_pointer_button_down_on() { + ui.data_mut(|d| d.remove::(hold_id)); + } // Double-click a polygon tool: Polygon Settings. if resp.double_clicked() && matches!(shown.id, "polygon" | "polygonFrame") { let cur = app.session.execute("tool.polygonSettings", &json!({})).unwrap_or_default(); @@ -113,12 +120,12 @@ pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) { { crate::menus::activate(app, cmd, &Value::Null); } - if g.len() > 1 - && (resp.secondary_clicked() - || resp.long_touched() - || (resp.is_pointer_button_down_on() - && ui.input(|i| i.pointer.press_start_time().is_some_and(|s| i.time - s > 0.35)))) - { + let held = + resp.is_pointer_button_down_on() && ui.input(|i| i.pointer.press_start_time().is_some_and(|s| i.time - s > 0.35)); + if g.len() > 1 && held { + ui.data_mut(|d| d.insert_temp(hold_id, true)); + } + if g.len() > 1 && (resp.secondary_clicked() || resp.long_touched() || held) { opened_now |= app.ui.flyout != Some(gi); app.ui.flyout = Some(gi); }