From 421c08c922959421523aa758589196a9a4545d7b Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Thu, 2 Jul 2020 11:43:44 -0700 Subject: [PATCH] Add missing method to FixedLayout --- cursive-core/src/views/fixed_layout.rs | 33 ++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/cursive-core/src/views/fixed_layout.rs b/cursive-core/src/views/fixed_layout.rs index c99b6fd..7283db3 100644 --- a/cursive-core/src/views/fixed_layout.rs +++ b/cursive-core/src/views/fixed_layout.rs @@ -1,8 +1,10 @@ -use crate::direction::{Absolute, Direction, Relative}; -use crate::event::{Event, EventResult, Key}; -use crate::rect::Rect; -use crate::view::IntoBoxedView; -use crate::{Printer, Vec2, View, With}; +use crate::{ + direction::{Absolute, Direction, Relative}, + event::{AnyCb, Event, EventResult, Key}, + rect::Rect, + view::{IntoBoxedView, Selector}, + {Printer, Vec2, View, With}, +}; /// 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(()) + } }