From af832a4afa72182f525b0ebdfbf48aca8d40cd90 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 20 Nov 2026 01:26:21 -0500 Subject: [PATCH] Keep paragraph frame during captured gestures --- crates/ui-egui/src/tools/edit_text_ui.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/tools/edit_text_ui.rs b/crates/ui-egui/src/tools/edit_text_ui.rs index a7aaf0a877..ea5c3f3e98 100644 --- a/crates/ui-egui/src/tools/edit_text_ui.rs +++ b/crates/ui-egui/src/tools/edit_text_ui.rs @@ -859,13 +859,23 @@ pub(crate) fn paragraph_controls( open_waiting(session, doc, page, &blocks, &boxes, geo); outline_closed(ui, body, session, page, &boxes, xf.rect.intersect(geo.viewport)); draw_move(ui, body, session, page, &boxes, press); - let framed = - hovered.filter(|(p, _)| *p == page).and_then(|(_, block)| blocks.get(block).zip(boxes.get(block).copied()).map(|(l, b)| (block, l, b))); + let held = blocks + .iter() + .enumerate() + .find_map(|(block, _)| craft::ui::runtime::pointer::active_part(ui.ctx(), width_frame_id(ui, page, block)).map(|_| (page, block))); + let framed = held + .or(hovered) + .filter(|(p, _)| *p == page) + .and_then(|(_, block)| blocks.get(block).zip(boxes.get(block).copied()).map(|(l, b)| (block, l, b))); edit = edit.or_else(|| width_frame(ui, body, session, doc, page, framed, geo)); } edit.or_else(|| editor_session(ui, body, session, doc, geo)) } +fn width_frame_id(ui: &egui::Ui, page: usize, block: usize) -> egui::Id { + ui.make_persistent_id(("paragraph-width", page, block)) +} + /// Opens the paragraph a switching click, or a click on grouped text, asked for once the document is /// ready for it. fn open_waiting( @@ -968,7 +978,10 @@ fn width_frame( .with_min_side(4.0) .with_handles(BoxHandles::Sides) .with_edge_band(EDGE_REACH); - let output = TransformBox::text_frame(tl!("Width").to_string(), Bind::given(state), start).rules(rules).show_at(ui, body.rect); + let output = TransformBox::text_frame(tl!("Width").to_string(), Bind::given(state), start) + .id(width_frame_id(ui, page, block)) + .rules(rules) + .show_at(ui, body.rect); let after = output.edit.events.iter().find_map(|event| match event { EditEvent::Commit { after, .. } | EditEvent::Set { after, .. } => Some(*after), _ => None,