Change OnEventView.inner to OnEventView.view

This breaks compatibility!
This commit is contained in:
Tymoteusz Jankowski 2018-01-26 22:30:23 +01:00
parent 057321abac
commit 4daf40e271

View File

@ -42,7 +42,7 @@ use view::{View, ViewWrapper};
/// .on_event(event::Key::Esc, |s| s.quit()); /// .on_event(event::Key::Esc, |s| s.quit());
/// ``` /// ```
pub struct OnEventView<T: View> { pub struct OnEventView<T: View> {
inner: T, view: T,
callbacks: HashMap<Event, Action<T>>, callbacks: HashMap<Event, Action<T>>,
} }
@ -72,7 +72,7 @@ impl<T: View> OnEventView<T> {
/// Wraps the given view in a new OnEventView. /// Wraps the given view in a new OnEventView.
pub fn new(view: T) -> Self { pub fn new(view: T) -> Self {
OnEventView { OnEventView {
inner: view, view: view,
callbacks: HashMap::new(), callbacks: HashMap::new(),
} }
} }
@ -206,7 +206,7 @@ impl<T: View> OnEventView<T> {
} }
impl<T: View> ViewWrapper for OnEventView<T> { impl<T: View> ViewWrapper for OnEventView<T> {
wrap_impl!(self.inner: T); wrap_impl!(self.view: T);
fn wrap_on_event(&mut self, event: Event) -> EventResult { fn wrap_on_event(&mut self, event: Event) -> EventResult {
let action = self.callbacks.get(&event).cloned(); let action = self.callbacks.get(&event).cloned();
@ -217,12 +217,12 @@ impl<T: View> ViewWrapper for OnEventView<T> {
if pre_child { if pre_child {
action action
.and_then(|a| (*a.callback)(&mut self.inner)) .and_then(|a| (*a.callback)(&mut self.view))
.unwrap_or_else(|| self.inner.on_event(event)) .unwrap_or_else(|| self.view.on_event(event))
} else { } else {
self.inner.on_event(event).or_else(|| { self.view.on_event(event).or_else(|| {
action action
.and_then(|a| (*a.callback)(&mut self.inner)) .and_then(|a| (*a.callback)(&mut self.view))
.unwrap_or(EventResult::Ignored) .unwrap_or(EventResult::Ignored)
}) })
} }