From 38ab0eaa6bbde560dc2babc331527b454bb68ce5 Mon Sep 17 00:00:00 2001 From: watchakorn-18k Date: Wed, 28 Oct 2026 22:27:29 +0700 Subject: [PATCH] docs(ui): document the right-click label pick and its tests Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_015wxxFg3gana4zaUKnyirTC --- crates/ui-egui/src/canvas/input.rs | 4 +++- crates/ui-egui/src/context_menu_tests.rs | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/canvas/input.rs b/crates/ui-egui/src/canvas/input.rs index e7f96152..75aa7c4e 100644 --- a/crates/ui-egui/src/canvas/input.rs +++ b/crates/ui-egui/src/canvas/input.rs @@ -243,7 +243,9 @@ fn send(app: &mut FigApp, kind: PointerKind, pos: Pos2, m: &egui::Modifiers) { } /// Right-click at screen `pos`: select what's under the pointer (`deep`: the nested layer), then -/// open the context menu there. +/// open the context menu there. A frame's name label counts as the frame, as on a press, so a +/// label drawn over its section picks the frame, not the section behind it. A layer that is +/// already selected keeps the whole selection. pub fn open_context_menu(app: &mut FigApp, pos: Pos2, deep: bool) { let p = app.to_page(pos); if let Ok(ds) = app.session.ds() { diff --git a/crates/ui-egui/src/context_menu_tests.rs b/crates/ui-egui/src/context_menu_tests.rs index 9e2c0d68..41c2e0be 100644 --- a/crates/ui-egui/src/context_menu_tests.rs +++ b/crates/ui-egui/src/context_menu_tests.rs @@ -85,10 +85,10 @@ fn copying_a_link_with_nothing_selected_copies_nothing() { assert!(u.app.ui.toast.is_none()); } +/// With a section selected, a right-click on either frame inside it links that frame, not the +/// section that was selected before. #[test] fn copying_a_link_on_a_frame_inside_a_selected_section_links_that_frame() { - // The section holds both frames; right-clicking each one must link that frame, not the section - // that was selected before. let mut s = Session::new(); let sec = id(&s.execute("node.create", &json!({"type": "section", "x": 0, "y": 0, "width": 800, "height": 400, "name": "Flow"})).unwrap()); let a = id(&s.execute("frame.create", &json!({"x": 20, "y": 60, "width": 300, "height": 200, "name": "main", "parent": sec})).unwrap()); @@ -107,10 +107,10 @@ fn copying_a_link_on_a_frame_inside_a_selected_section_links_that_frame() { } } +/// A frame inside a section has its label above it, inside the section: a right-click there picks +/// the frame whose label it is, not the section behind the label. #[test] fn copying_a_link_from_a_frames_name_label_links_that_frame() { - // A frame inside a section has its label above it, inside the section: a right-click there - // must pick the frame whose label it is, not the section behind the label. let mut s = Session::new(); let sec = id(&s.execute("node.create", &json!({"type": "section", "x": 0, "y": 0, "width": 800, "height": 400, "name": "Flow"})).unwrap()); let a = id(&s.execute("frame.create", &json!({"x": 20, "y": 80, "width": 300, "height": 200, "name": "main", "parent": sec})).unwrap());