From 8237855202d58e28e912a83e612397b4300a3f3b Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Wed, 28 Oct 2020 20:59:36 +0100 Subject: Add option to abort adding a rectangle --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e6c85ea..1456684 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,6 @@ use piston_window::grid::Grid; use piston_window::rectangle::{Border, Rectangle}; use piston_window::*; use sdl2_window::Sdl2Window; -use std::cmp; pub const MIN_PIXELS_PER_M: f64 = 0.5; pub const MAX_PIXELS_PER_M: f64 = 10_000.; @@ -87,6 +86,10 @@ fn main() { starting_rect_point = Some(mouse_pos); } } + // Abort drawing a rectangle when clicking with the right mouse button + if let Some(Button::Mouse(MouseButton::Right)) = e.press_args() { + starting_rect_point = None; + } // Close the window when the user presses escape if let Some(Button::Keyboard(Key::Escape)) = e.press_args() { -- cgit v1.2.3-70-g09d2