diff --git a/docs/TODO_ux.md b/docs/TODO_ux.md index da60c3f20d..55618ceefd 100644 --- a/docs/TODO_ux.md +++ b/docs/TODO_ux.md @@ -27,7 +27,6 @@ - optionally limit canvas scrolling/zooming to some map bounds - top menu doesnt know when we have a more urgent input thing going! - cant use G for geom debug mode and contextual polygon debug -- on a menu with preselected thing, clicking ANYWHERE does stuff... - X on all menus - when dragging, dont give mouse movement to UI elements - start context menu when left click releases and we're not dragging diff --git a/docs/design/notes/demand.md b/docs/design/notes/demand.md index b7035751d2..9b46cdea88 100644 --- a/docs/design/notes/demand.md +++ b/docs/design/notes/demand.md @@ -1,5 +1,6 @@ # Demand data +- https://en.wikipedia.org/wiki/Transportation_forecasting - https://data.seattle.gov/Transportation/2016-Traffic-Flow-Counts/f22b-ywut - counts per aterial diff --git a/ezgui/src/widgets/menu.rs b/ezgui/src/widgets/menu.rs index abecd4c5cd..40c7c08db7 100644 --- a/ezgui/src/widgets/menu.rs +++ b/ezgui/src/widgets/menu.rs @@ -7,6 +7,7 @@ pub struct Menu { // The bool is whether this choice is active or not choices: Vec<(Option, String, bool, T)>, current_idx: Option, + mouse_in_bounds: bool, keys_enabled: bool, pos: Position, @@ -78,6 +79,8 @@ impl Menu { .collect(), current_idx: if keys_enabled { Some(0) } else { None }, keys_enabled, + // TODO Bit of a hack, but eh. + mouse_in_bounds: !keys_enabled, pos, row_height, @@ -106,7 +109,7 @@ impl Menu { if ev == Event::LeftMouseButtonDown { if let Some(i) = self.current_idx { let (_, choice, active, data) = self.choices[i].clone(); - if active { + if active && self.mouse_in_bounds { return InputResult::Done(choice, data); } else { return InputResult::StillActive; @@ -117,23 +120,25 @@ impl Menu { } else if ev == Event::RightMouseButtonDown { return InputResult::Canceled; } else if let Event::MouseMovedTo(pt) = ev { - let mut matched = false; - for i in 0..self.choices.len() { - if self.choices[i].2 - && self - .first_choice_row - .translate(0.0, (i as f64) * self.row_height) - .contains(pt) - { - self.current_idx = Some(i); - matched = true; - break; + if !canvas.is_dragging() { + for i in 0..self.choices.len() { + if self.choices[i].2 + && self + .first_choice_row + .translate(0.0, (i as f64) * self.row_height) + .contains(pt) + { + self.current_idx = Some(i); + self.mouse_in_bounds = true; + return InputResult::StillActive; + } } + self.mouse_in_bounds = false; + if !self.keys_enabled { + self.current_idx = None; + } + return InputResult::StillActive; } - if !matched && !self.keys_enabled { - self.current_idx = None; - } - return InputResult::StillActive; } // Handle keys