aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Dußin2020-10-28 20:59:36 +0100
committerArne Dußin2020-10-28 20:59:36 +0100
commit8237855202d58e28e912a83e612397b4300a3f3b (patch)
tree8abcf6dc509b0208491df860dafaaaeb6ae1f302
parent3ece8e36bd7c1aa08374ff8ffa0f7206976746fd (diff)
downloadgraf_karto-8237855202d58e28e912a83e612397b4300a3f3b.tar.gz
graf_karto-8237855202d58e28e912a83e612397b4300a3f3b.zip
Add option to abort adding a rectangle
-rw-r--r--src/main.rs5
1 files changed, 4 insertions, 1 deletions
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() {