diff --git a/src/.gui.rs.swp b/src/.gui.rs.swp new file mode 100644 index 0000000..756ca05 Binary files /dev/null and b/src/.gui.rs.swp differ diff --git a/src/gui.rs b/src/gui.rs index aeb74fc..3e5fd8c 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -11,7 +11,7 @@ pub fn main() -> iced::Result { struct Main { ntfy: String, - configuring: bool, + configuring: Option<&char>, inputs: Inputs, } @@ -60,7 +60,7 @@ impl Application for Main { fn new(_flags: ()) -> (Self, Command) { return (Self { ntfy: String::from(":wave:"), - configuring: false, + configuring: None, inputs: Inputs{ stick: Stick { up: 'w', @@ -84,7 +84,7 @@ impl Application for Main { fn update(&mut self, msg: Message) -> Command { match msg { - Message::EventOccurred(event) if self.configuring => { + Message::EventOccurred(event) if self.configuring.is_some() => { match event { iced::event::Event::Keyboard(keyboard::Event::KeyPressed{ key_code, @@ -92,14 +92,16 @@ impl Application for Main { .. }) => { self.ntfy = format!("would set {:?}", key_code); - self.configuring = false; + self.configuring = None; }, _ => {}, } }, Message::EventOccurred(event) if ! self.configuring => {}, _ => { - self.configuring = true; + self.configuring = Some(match event { + _ => None, + }); self.ntfy = format!("push a key to bind to {:?}", msg); }, }