diff --git a/cursive-core/src/event.rs b/cursive-core/src/event.rs index a9c0ca52..63de73cb 100644 --- a/cursive-core/src/event.rs +++ b/cursive-core/src/event.rs @@ -533,6 +533,16 @@ pub enum Event { } impl Event { + /// Returns the character, if `self` is a char event. + pub fn char(&self) -> Option { + match *self { + Event::Char(c) => Some(c), + Event::AltChar(c) => Some(c), + Event::CtrlChar(c) => Some(c), + _ => None, + } + } + /// Returns the position of the mouse, if `self` is a mouse event. pub fn mouse_position(&self) -> Option { if let Event::Mouse { position, .. } = *self { @@ -542,7 +552,7 @@ impl Event { } } - /// Returns a mutable reference to the position of the mouse/ + /// Returns a mutable reference to the position of the mouse. /// /// Returns `None` if `self` is not a mouse event. pub fn mouse_position_mut(&mut self) -> Option<&mut Vec2> {