pub struct Tabs<'a, M> { /* private fields */ }Expand description
Children one at a time, under a bar of their titles (#478). Every tab keeps its state while another shows; hidden tabs still get ticks and resizes. Alt+Right or Ctrl+PageDown shows the next tab, Alt+Left or Ctrl+PageUp the previous, Alt+1 to Alt+9 a tab by number, and a click on a title that tab. These come before the tab’s own keys; Tab and Shift+Tab move focus inside the tab shown.
Implementations§
Source§impl<'a, M> Tabs<'a, M>
impl<'a, M> Tabs<'a, M>
pub fn new() -> Tabs<'a, M>
Sourcepub fn tab(
self,
title: impl Into<String>,
child: impl Component<Output = M> + 'a,
) -> Self
pub fn tab( self, title: impl Into<String>, child: impl Component<Output = M> + 'a, ) -> Self
Add a tab.
Sourcepub fn push(&mut self, title: impl Into<String>, child: Child<'a, M>)
pub fn push(&mut self, title: impl Into<String>, child: Child<'a, M>)
Add a tab to tabs already built.
Sourcepub fn styles(self, selected: Style, unselected: Style) -> Self
pub fn styles(self, selected: Style, unselected: Style) -> Self
The styles of the shown tab’s title and the others’.
Sourcepub fn on(
self,
action: &str,
keys: impl IntoIterator<Item = Key>,
description: &str,
handler: impl FnMut() -> Flow<M> + 'a,
) -> Self
pub fn on( self, action: &str, keys: impl IntoIterator<Item = Key>, description: &str, handler: impl FnMut() -> Flow<M> + 'a, ) -> Self
Run handler when one of keys bubbles up unused by the
focused child: an action of yours, listed in the keymap under
this container’s context.
Sourcepub fn shortcut(
self,
action: &str,
keys: impl IntoIterator<Item = Key>,
description: &str,
handler: impl FnMut() -> Flow<M> + 'a,
) -> Self
pub fn shortcut( self, action: &str, keys: impl IntoIterator<Item = Key>, description: &str, handler: impl FnMut() -> Flow<M> + 'a, ) -> Self
Run handler when one of keys is pressed, before the focused
child sees it.
Sourcepub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
pub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
Make keys do this container’s action (focus-next, and the
container’s own); no keys unbinds it.
Sourcepub fn own_keymap(&self) -> &Keymap
pub fn own_keymap(&self) -> &Keymap
This container’s own bindings, without its children’s.
Sourcepub fn with_mouse(self, on: bool) -> Self
pub fn with_mouse(self, on: bool) -> Self
Report the mouse even when no child asks for it: for a click to focus a child, or a border to drag.
pub fn titles(&self) -> &[String]
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get(&self, index: usize) -> Option<&(dyn Component<Output = M> + 'a)>
pub fn get(&self, index: usize) -> Option<&(dyn Component<Output = M> + 'a)>
Tab index’s child.
pub fn get_mut( &mut self, index: usize, ) -> Option<&mut (dyn Component<Output = M> + 'a)>
Trait Implementations§
Source§impl<M> Component for Tabs<'_, M>
impl<M> Component for Tabs<'_, M>
type Output = M
Source§fn start(&mut self, context: &Context<'_>) -> Flow<M>
fn start(&mut self, context: &Context<'_>) -> Flow<M>
Done or Cancel finishes the component
without waiting for an event. The default does nothing.Source§fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<M>
fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<M>
Outcome::Interrupted.Source§fn tick(&self) -> Option<Duration>
fn tick(&self) -> Option<Duration>
Event::Tick, for a spinner or a
countdown. None (the default): never.Source§fn mouse(&self) -> bool
fn mouse(&self) -> bool
run then enables mouse reporting
for the session.Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
keymap). A container’s include its focused
child’s, before its own. The default declares none.Source§fn focusable(&self) -> bool
fn focusable(&self) -> bool
Source§fn focus_step(&mut self, forward: bool) -> bool
fn focus_step(&mut self, forward: bool) -> bool
forward) or previous focus stop inside
this component, for Tab and Shift+Tab. false when there is none
after the current one, so the container moves on to its next
child. The default, for a component that is one stop: false.Source§fn focus_enter(&mut self, forward: bool) -> bool
fn focus_enter(&mut self, forward: bool) -> bool
forward,
at the last otherwise. false when nothing in it can take focus.
The default: whether the component is focusable.Source§fn default_value(&self) -> Option<Self::Output>
fn default_value(&self) -> Option<Self::Output>
None: there is none.Auto Trait Implementations§
impl<'a, M> !RefUnwindSafe for Tabs<'a, M>
impl<'a, M> !Send for Tabs<'a, M>
impl<'a, M> !Sync for Tabs<'a, M>
impl<'a, M> !UnwindSafe for Tabs<'a, M>
impl<'a, M> Freeze for Tabs<'a, M>
impl<'a, M> Unpin for Tabs<'a, M>
impl<'a, M> UnsafeUnpin for Tabs<'a, M>where
Group<'a, M>: UnsafeUnpin,
Bindings<'a, M>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> ComponentExt for Cwhere
C: Component,
impl<C> ComponentExt for Cwhere
C: Component,
Source§fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
M’s flow: Flow::Done(m) to
finish the whole composition with m, Flow::Continue to carry on
(the component stays, showing its answer, and focus moves past it).
Cancelling cancels the composition unless
on_cancel says otherwise.