Add missing method to FixedLayout

This commit is contained in:
Alexandre Bury 2020-07-02 11:43:44 -07:00
parent f5687f5eab
commit 421c08c922

View File

@ -1,8 +1,10 @@
use crate::direction::{Absolute, Direction, Relative}; use crate::{
use crate::event::{Event, EventResult, Key}; direction::{Absolute, Direction, Relative},
use crate::rect::Rect; event::{AnyCb, Event, EventResult, Key},
use crate::view::IntoBoxedView; rect::Rect,
use crate::{Printer, Vec2, View, With}; view::{IntoBoxedView, Selector},
{Printer, Vec2, View, With},
};
/// Arranges its children in a fixed layout. /// Arranges its children in a fixed layout.
/// ///
@ -318,4 +320,25 @@ impl View for FixedLayout {
} }
} }
} }
fn call_on_any<'a>(
&mut self,
selector: &Selector<'_>,
callback: AnyCb<'a>,
) {
for child in &mut self.children {
child.view.call_on_any(selector, callback);
}
}
fn focus_view(&mut self, selector: &Selector<'_>) -> Result<(), ()> {
for (i, child) in self.children.iter_mut().enumerate() {
if child.view.focus_view(selector).is_ok() {
self.focus = i;
return Ok(());
}
}
Err(())
}
} }