mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-10 21:11:52 +00:00
M5: a right-click on a group member selects its group
Review follow-up on #4358: the secondary-click path still selected with cx.hit, which misses a group subordinate lying outside its primary's rectangle and cleared the selection, so the menu offered page actions instead of the comment's. It now uses the group-aware cx.click_hit, as the click does (ISO 32000-2 §12.5.6.2). Double-click editing goes through the same group-aware hit as the click since the rebase onto main, where the press owner comes from the module's hit test; the test covers both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
This commit is contained in:
1 parent
6085c9110e
commit
f43a8af538
2 files changed
+18
-1
No files matched your search
@@ -31,7 +31,8 @@ pub(crate) fn page_input(ui: &egui::Ui, resp: &egui::Response, cx: &PageCx<'_>,
|
||||
&& let Some(p) = pointer.filter(|p| page_rect.contains(*p))
|
||||
{
|
||||
cv.context_at = Some((cx.page, cx.to_user(p)));
|
||||
cv.selected = cx.hit(p).map(|a| (cx.page, a.index));
|
||||
// On a group subordinate, its group (the primary), so the menu offers the comment's actions.
|
||||
cv.selected = cx.click_hit(p).map(|a| (cx.page, a.index));
|
||||
}
|
||||
let gestures = Gestures { ui, resp, cx, pointer, origin, page_rect, pressed_here, over_page };
|
||||
match cx.tool {
|
||||
|
||||
@@ -3062,4 +3062,20 @@ fn a_group_is_one_comment_in_the_panel_and_on_the_page() {
|
||||
let p = at(&h, 60.0, 50.0);
|
||||
click(&mut h, p);
|
||||
assert_eq!(h.state().views[0].comments.selected, Some((0, 0)));
|
||||
// #4358 review: a right-click on the Circle selects the group too, so the menu is the
|
||||
// comment's, and a double-click there edits the group's text, which is the Square's.
|
||||
h.state_mut().views[0].comments.selected = None;
|
||||
let p = at(&h, 220.0, 150.0);
|
||||
h.hover_at(p);
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
|
||||
h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().views[0].comments.selected, Some((0, 0)), "a right-click on the Circle selects its group");
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.run_steps(2);
|
||||
h.state_mut().views[0].comments.selected = None;
|
||||
crate::support::input::double_click(&mut h, p);
|
||||
let composer = h.state().views[0].comments.composer.as_ref().map(|c| c.text.clone());
|
||||
assert_eq!(composer.as_deref(), Some("Primary"), "a double-click on the Circle edits its group's text");
|
||||
}
|
||||
Reference in new issue
Block a user