reset selection state after hiding something

This commit is contained in:
Dustin Carlino 2018-07-03 09:44:39 -07:00
parent cacf3aea62
commit d66d070dd6
2 changed files with 3 additions and 2 deletions

View File

@ -248,7 +248,7 @@ impl Hider {
} }
} }
pub fn event(&mut self, input: &mut UserInput, state: &SelectionState) { pub fn event(&mut self, input: &mut UserInput, state: &mut SelectionState) {
if input.unimportant_key_pressed(Key::K, "Press k to unhide everything") { if input.unimportant_key_pressed(Key::K, "Press k to unhide everything") {
println!("Unhiding {} things", self.items.len()); println!("Unhiding {} things", self.items.len());
self.items.clear(); self.items.clear();
@ -264,6 +264,7 @@ impl Hider {
if input.unimportant_key_pressed(Key::H, &format!("Press h to hide {:?}", id)) { if input.unimportant_key_pressed(Key::H, &format!("Press h to hide {:?}", id)) {
self.items.insert(id); self.items.insert(id);
println!("Hiding {:?}", id); println!("Hiding {:?}", id);
*state = SelectionState::Empty;
} }
} }
} }

View File

@ -421,7 +421,7 @@ impl gui::GUI for UI {
let item = self.mouseover_something(window_size); let item = self.mouseover_something(window_size);
self.current_selection_state = self.current_selection_state.handle_mouseover(item); self.current_selection_state = self.current_selection_state.handle_mouseover(item);
} }
self.hider.event(input, &self.current_selection_state); self.hider.event(input, &mut self.current_selection_state);
// TODO can't get this destructuring expressed right // TODO can't get this destructuring expressed right
let (new_selection_state, new_event_loop_mode) = let (new_selection_state, new_event_loop_mode) =
self.current_selection_state self.current_selection_state