mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 10:50:40 +00:00
Reject events for disabled views
This commit is contained in:
parent
bb98be1132
commit
55c4aa2716
@ -160,6 +160,10 @@ impl View for Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) -> EventResult {
|
fn on_event(&mut self, event: Event) -> EventResult {
|
||||||
|
if !self.enabled {
|
||||||
|
return EventResult::Ignored;
|
||||||
|
}
|
||||||
|
|
||||||
// eprintln!("{:?}", event);
|
// eprintln!("{:?}", event);
|
||||||
// eprintln!("{:?}", self.req_size());
|
// eprintln!("{:?}", self.req_size());
|
||||||
let width = self.label.width();
|
let width = self.label.width();
|
||||||
|
@ -158,6 +158,9 @@ impl View for Checkbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) -> EventResult {
|
fn on_event(&mut self, event: Event) -> EventResult {
|
||||||
|
if !self.enabled {
|
||||||
|
return EventResult::Ignored;
|
||||||
|
}
|
||||||
match event {
|
match event {
|
||||||
Event::Key(Key::Enter) | Event::Char(' ') => self.toggle(),
|
Event::Key(Key::Enter) | Event::Char(' ') => self.toggle(),
|
||||||
Event::Mouse {
|
Event::Mouse {
|
||||||
|
@ -598,6 +598,9 @@ impl View for EditView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) -> EventResult {
|
fn on_event(&mut self, event: Event) -> EventResult {
|
||||||
|
if !self.enabled {
|
||||||
|
return EventResult::Ignored;
|
||||||
|
}
|
||||||
match event {
|
match event {
|
||||||
Event::Char(ch) => {
|
Event::Char(ch) => {
|
||||||
return EventResult::Consumed(Some(self.insert(ch)));
|
return EventResult::Consumed(Some(self.insert(ch)));
|
||||||
|
@ -209,6 +209,10 @@ impl<T: 'static> View for RadioButton<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) -> EventResult {
|
fn on_event(&mut self, event: Event) -> EventResult {
|
||||||
|
if !self.enabled() {
|
||||||
|
return EventResult::Ignored;
|
||||||
|
}
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::Key(Key::Enter) | Event::Char(' ') => self.select(),
|
Event::Key(Key::Enter) | Event::Char(' ') => self.select(),
|
||||||
Event::Mouse {
|
Event::Mouse {
|
||||||
|
@ -954,6 +954,10 @@ impl<T: 'static> View for SelectView<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) -> EventResult {
|
fn on_event(&mut self, event: Event) -> EventResult {
|
||||||
|
if !self.enabled {
|
||||||
|
return EventResult::Ignored;
|
||||||
|
}
|
||||||
|
|
||||||
if self.popup {
|
if self.popup {
|
||||||
self.on_event_popup(event)
|
self.on_event_popup(event)
|
||||||
} else {
|
} else {
|
||||||
|
@ -527,6 +527,10 @@ impl View for TextArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) -> EventResult {
|
fn on_event(&mut self, event: Event) -> EventResult {
|
||||||
|
if !self.enabled {
|
||||||
|
return EventResult::Ignored;
|
||||||
|
}
|
||||||
|
|
||||||
let mut fix_scroll = true;
|
let mut fix_scroll = true;
|
||||||
match event {
|
match event {
|
||||||
Event::Char(ch) => self.insert(ch),
|
Event::Char(ch) => self.insert(ch),
|
||||||
|
Loading…
Reference in New Issue
Block a user