Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Hold the guide-drag cursor only while the primary button is down

Brandon Thomas794b7a29de1c
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 19bcb87e3..bf8a88563 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -744,8 +744,10 @@ pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {
None => c,
};
// A ruler guide being dragged keeps the cursor across it until it is dropped, over the
- // canvas too (the tool's cursor took over as soon as the pointer left the ruler).
- let c = match ui.data(|d| d.get_temp::<GuideDrag>(egui::Id::unique(GUIDE_DRAG))).map(|g| g.orientation) {
+ // canvas too (the tool's cursor took over as soon as the pointer left the ruler). Only
+ // while the button is down: a drag state left behind by a skipped release doesn't stick.
+ let dragging = ui.input(|i| i.pointer.primary_down());
+ let c = match ui.data(|d| d.get_temp::<GuideDrag>(egui::Id::unique(GUIDE_DRAG))).filter(|_| dragging).map(|g| g.orientation) {
Some(designcraft_doc::Orientation::Horizontal) => Cursor::ResizeV,
Some(designcraft_doc::Orientation::Vertical) => Cursor::ResizeH,
None => c,