From 05f30c167403671a732e9f6cd46c5b35d96ecccd Mon Sep 17 00:00:00 2001 From: kaltenbrunnermarkus <153593707+kaltenbrunnermarkus@users.noreply.github.com> Date: Sat, 31 Oct 2026 20:05:28 +0000 Subject: [PATCH] Browser: a click just past a feature's name selects it instead of opening its sketch (#10079) (#10213) * claim: #10079 * Browser: a click just past a feature's name selects it instead of opening its sketch (#10079) The Edit Profile Sketch button on a browser feature row began 2 points after the name, so a click that landed just past the name, or a press on the name that slipped a few points before its release, opened the profile sketch. The button now starts 8 points after the name, wider than egui's 6-point click slop; the gap selects the row like the name does. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Markus Kaltenbrunner Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/browser/features.rs | 52 ++++++++++++++++++++++++++ crates/ui-egui/src/ui_kit/tree.rs | 8 +++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/browser/features.rs b/crates/ui-egui/src/browser/features.rs index a4d269c76..145bf4316 100644 --- a/crates/ui-egui/src/browser/features.rs +++ b/crates/ui-egui/src/browser/features.rs @@ -826,6 +826,58 @@ mod tests { assert!(labels.contains(&block_name), "a rolled-back feature stays listed: {labels:?}"); } + /// #10079: three extrusions of one visible sketch, the first renamed. A click just past the end + /// of a feature's name, or a press on the name that slips a few points before its release, + /// selects the feature; only the sketch button itself opens the sketch. + #[test] + fn clicking_just_past_a_feature_name_selects_it_without_opening_its_sketch() { + let mut h = Harness::new(); + let sketch = h.app.run("sketch.create", json!({"plane":"XY","name":"Sketch1"})).unwrap()["sketch"].as_u64().unwrap(); + for (p0, p1) in [([0, 0], [10, 10]), ([20, 0], [30, 10]), ([40, 0], [50, 10])] { + h.app.run("sketch.rectangle.two_point", json!({"p0":p0,"p1":p1})).unwrap(); + } + h.app.run("sketch.finish", json!({})).unwrap(); + let mut ids = Vec::new(); + for profile in 0..3 { + let made = h.app.run("solid.extrude", json!({"sketch":sketch,"profiles":[profile],"distance":5})).unwrap(); + ids.push(made["feature"].as_u64().unwrap()); + if profile == 0 { + h.app.run("timeline.rename", json!({"feature":ids[0],"name":"Lid"})).unwrap(); + } + } + // The sketch stays shown, as in the report. + crate::browser::set_sketch_visible(&mut h.app, sketch, true); + h.app.tree.expanded.insert("c0/features".into()); + h.settle(); + assert!(crate::browser::sketch_visible(&h.app, sketch)); + let press = |h: &mut Harness, at: Pos2, pressed: bool| { + h.frame_with(vec![egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }]); + }; + // A press at `from` released at `to`, then long enough that the next click is not a double. + let click = |h: &mut Harness, from: Pos2, to: Pos2| { + h.frame_with(vec![egui::Event::PointerMoved(from)]); + press(h, from, true); + h.frame_with(vec![egui::Event::PointerMoved(to)]); + press(h, to, false); + h.frames(30); + }; + for (round, id) in ids.iter().chain(&ids).enumerate() { + let name = h.app.session.doc.feature(*id).unwrap().name.clone(); + for (from, to) in [(1.0, 1.0), (5.0, 5.0), (-2.0, 4.0)] { + // Selected rows draw their name in semibold, wider: measure it each time. + let label = crate::scenario::rect_of(&format!("row_label:{name}")).unwrap(); + let at = |dx: f32| pos2(label.right() + dx, label.center().y); + click(&mut h, at(from), at(to)); + assert_eq!(h.app.session.active_sketch, None, "round {round}: {name} clicked {from}..{to} points past its name opened the sketch"); + assert!(h.app.dialog.is_none(), "round {round}: {name} opened a dialog"); + assert_eq!(h.app.session.selection, [Sel::Feature { id: *id }], "round {round}: {name} {from}..{to}"); + } + } + h.step(&json!({"click": {"handle": "action:Extrude1"}})).unwrap(); + h.frames(2); + assert_eq!(h.app.session.active_sketch, Some(sketch), "the sketch button still opens the sketch"); + } + fn settle_heavy(h: &mut Harness) { for _ in 0..500 { if h.app.deferred.is_none() && h.app.deferred_queue.is_empty() { diff --git a/crates/ui-egui/src/ui_kit/tree.rs b/crates/ui-egui/src/ui_kit/tree.rs index 781d499ba..76af5eee4 100644 --- a/crates/ui-egui/src/ui_kit/tree.rs +++ b/crates/ui-egui/src/ui_kit/tree.rs @@ -225,7 +225,8 @@ pub(crate) fn tree_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp { let radio_x = x + 14.0 + slot + 6.0; let radio_r = Rect::from_center_size(pos2(radio_x, cy), vec2(t.space_12 + t.space_3, r.height())); // The button right after the name takes room from the label; it is placed once the label is laid out. - let name_action_width = if row.action.is_some() { 22.0 } else { 0.0 }; + let (name_action_gap, name_action_size) = (t.space_8, t.space_16 + t.space_4); + let name_action_width = if row.action.is_some() { name_action_gap + name_action_size } else { 0.0 }; let at = |p: Pos2| -> u8 { if !row.actions.is_empty() && p.x >= action_left { 4 @@ -380,7 +381,10 @@ pub(crate) fn tree_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp { bx += 15.0; } // The name's action button sits right after the label; a press on it is not a press on the row. - let action_r = Rect::from_min_size(pos2(x + lw + 2.0, r.top()), vec2(t.space_16 + t.space_4, r.height())); + // The gap before it belongs to the row: a click that lands just past the end of the name, or + // a press on the name that slips a few points before its release, selects the row instead of + // opening the feature's sketch (#10079). The gap is wider than egui's click slop (6 points). + let action_r = Rect::from_min_size(pos2(x + lw + name_action_gap, r.top()), vec2(name_action_size, r.height())); let over_action = |p: Option| row.action.is_some() && p.is_some_and(|p| action_r.contains(p)); let action_hover = over_action(resp.hover_pos()); let action_click = over_action(resp.interact_pointer_pos());