diff --git a/README.md b/README.md index 798ab14..eaf039c 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ terminal.draw(|frame| { To handle key events: ```rust -heh.handle_input(crossterm::event::Event::Key(/* */)).unwrap(); +heh.handle_input(&crossterm::event::Event::Key(/* */)).unwrap(); ``` See the [binsider](https://github.com/orhun/binsider) project for an example use case. diff --git a/src/app.rs b/src/app.rs index 81fe54c..d500e11 100644 --- a/src/app.rs +++ b/src/app.rs @@ -205,7 +205,7 @@ impl Application { loop { self.render_display()?; let event = event::read()?; - if !self.handle_input(event)? { + if !self.handle_input(&event)? { break; } } @@ -253,17 +253,17 @@ impl Application { /// # Errors /// /// This errors when handling the key event fails. - pub fn handle_input(&mut self, event: Event) -> Result> { + pub fn handle_input(&mut self, event: &Event) -> Result> { match event { Event::Key(key) => { if key.kind == KeyEventKind::Press { self.labels.notification.clear(); - return input::handle_key_input(self, key); + return input::handle_key_input(self, *key); } } Event::Mouse(mouse) => { self.labels.notification.clear(); - input::handle_mouse_input(self, mouse); + input::handle_mouse_input(self, *mouse); } Event::Resize(_, _) | Event::FocusGained | Event::FocusLost | Event::Paste(_) => {} }