From fb596a4e3b6dd414241f9525e7efe200949428d6 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Thu, 4 Feb 2021 22:32:52 +0100 Subject: Dimension ruling state cancelled on mouse interaction This fixes the dimension indicator staying in a ruling state, while something else may have been selected. --- src/client/gui/dimension_indicator.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/gui/dimension_indicator.rs b/src/client/gui/dimension_indicator.rs index ebad78b..7d5fd65 100644 --- a/src/client/gui/dimension_indicator.rs +++ b/src/client/gui/dimension_indicator.rs @@ -2,7 +2,7 @@ //! manually change the size of them in a precise manner should need be. use crate::client::colours::DEFAULT_COLOURS; -use crate::client::input::{Button, Input, Scancode}; +use crate::client::input::{Button, Input, MouseButton, Scancode}; use crate::client::map::Map; use crate::client::transform::Transform; use crate::client::Editor; @@ -112,6 +112,14 @@ impl DimensionIndicator { } fn update_ruling(&mut self, editor: &Editor, input: &mut Input) { + // Abort the ruling state when doing anything with the mouse. + if input.poll_global(&Button::Mouse(MouseButton::Left).into()) + || input.poll_global(&Button::Mouse(MouseButton::Right).into()) + { + self.state = State::Watching; + return; + } + // Get the currently edited dimension for processing. let (edited_dim, editing_x, text_pipe) = match &mut self.state { State::Watching => panic!("Called ruler update when in watching state"), @@ -154,7 +162,9 @@ impl DimensionIndicator { match key { // Add a decimal point to the dimension if possible. '.' => { + println!("Adding dec point?"); if !edited_dim.contains('.') { + println!("Adding dec point!"); edited_dim.push('.'); } // Nothing changed here, since there is an implicit .0 at the end. -- cgit v1.2.3-70-g09d2