make contextmenu aware of commands
e.g. to process vim-like keybindings for navigation fixes #108, fixes #157, fixes #178, fixes #199, fixes #250
This commit is contained in:
@@ -2,12 +2,22 @@ use cursive::event::{Event, EventResult};
|
||||
use cursive::view::{View, ViewWrapper};
|
||||
|
||||
pub struct Modal<T: View> {
|
||||
block_events: bool,
|
||||
inner: T,
|
||||
}
|
||||
|
||||
impl<T: View> Modal<T> {
|
||||
pub fn new(inner: T) -> Self {
|
||||
Modal { inner }
|
||||
Modal {
|
||||
block_events: true,
|
||||
inner,
|
||||
}
|
||||
}
|
||||
pub fn new_ext(inner: T) -> Self {
|
||||
Modal {
|
||||
block_events: false,
|
||||
inner,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +26,10 @@ impl<T: View> ViewWrapper for Modal<T> {
|
||||
fn wrap_on_event(&mut self, ch: Event) -> EventResult {
|
||||
match self.inner.on_event(ch) {
|
||||
EventResult::Consumed(cb) => EventResult::Consumed(cb),
|
||||
_ => EventResult::Consumed(None),
|
||||
_ => match self.block_events {
|
||||
true => EventResult::Consumed(None),
|
||||
false => EventResult::Ignored,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user