pub struct Tabs<Msg> { /* private fields */ }Expand description
A row of tabs. The open tab is a raised surface; tabs are never boxed or bracketed.
With no options it is the plainest strip: keys while focused are ←/→ (or h/l) to open the neighbouring tab, and 1–9 open a tab by number when numbers are shown. When the tabs do not fit, arrow controls appear at both ends: a click scrolls one tab, and ctrl+PgUp, ctrl+PgDn and the wheel do the same. Opening a tab brings it into view.
Capabilities are independent options:
closable: a faint×on every tab that brightens on hover; clicking it, a middle click on the tab or ctrl+w closes the tab.pinnedtabs cannot be closed.tab_width: fit, fixed or filling tabs.overflow: scroll arrows or a menu of hidden tabs.reorderable: drag a tab to move it; a ghost follows the pointer and the tabs make room where it will land. ctrl+shift+←/→ moves the open tab. Held on a scroll arrow or past an end of an overflowing strip, the dragged tab scrolls the strip: one tab after 400 ms, then one every 150 ms (sooner the further past the end) until the pointer leaves or the strip ends; the arrow lights up meanwhile and the drop slot follows the tabs coming into view.on_drag_scrollreports each step.context_menu: a right click on a tab opens a menu of actions for it at the pointer; the menu key or shift+F10 opens the menu of the open tab. Without it a right click does nothing.
Style keys: tab with hover, selected, focus; tab-index for numbers; close-mark
(with active on a raised tab, hover under the pointer); tab-arrow (bg, fg, pillar)
with hover, pressed, disabled; tab-menu (bg, fg, pillar) with hover, active
while its menu is open; tab-ghost and tab-drop (bg) while dragging; popup-menu,
popup-item, popup-check for the menu of hidden tabs; the keys of
ContextItem for the context menu.
Implementations§
Source§impl<Msg: 'static> Tabs<Msg>
impl<Msg: 'static> Tabs<Msg>
Sourcepub fn new(labels: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn new(labels: impl IntoIterator<Item = impl Into<String>>) -> Self
Tabs with labels; the first is open.
Sourcepub fn numbered(self, numbered: bool) -> Self
pub fn numbered(self, numbered: bool) -> Self
Shows 1, 2, 3… before the labels and lets number keys open tabs.
Sourcepub fn on_select(self, message: impl Fn(usize) -> Msg + 'static) -> Self
pub fn on_select(self, message: impl Fn(usize) -> Msg + 'static) -> Self
Message for opening tab index.
Sourcepub fn closable(self, message: impl Fn(usize) -> Msg + 'static) -> Self
pub fn closable(self, message: impl Fn(usize) -> Msg + 'static) -> Self
Makes tabs closable: message(index) asks the application to close tab index.
TabEdit::Close applies it to the application’s list.
Sourcepub fn pinned(self, indices: impl IntoIterator<Item = usize>) -> Self
pub fn pinned(self, indices: impl IntoIterator<Item = usize>) -> Self
Tabs that cannot be closed, such as a pinned start page. They show no close mark.
Sourcepub fn tab_width(self, width: TabWidth) -> Self
pub fn tab_width(self, width: TabWidth) -> Self
How wide the tabs are; TabWidth::Fit by default.
Sourcepub fn overflow(self, overflow: Overflow) -> Self
pub fn overflow(self, overflow: Overflow) -> Self
What happens when the tabs do not fit; Overflow::Arrows by default.
Sourcepub fn reorderable(
self,
message: impl Fn(usize, usize) -> Msg + 'static,
) -> Self
pub fn reorderable( self, message: impl Fn(usize, usize) -> Msg + 'static, ) -> Self
Makes tabs reorderable: message(from, to) asks the application to move a tab.
TabEdit::Move applies it to the application’s list.
Sourcepub fn on_drag_scroll(self, message: impl Fn(usize) -> Msg + 'static) -> Self
pub fn on_drag_scroll(self, message: impl Fn(usize) -> Msg + 'static) -> Self
Message for each step a dragged tab scrolls an overflowing strip, with the position of the first tab now in view (counted from 0), e.g. to log it. Only reorderable strips scroll this way.
Gives every tab a context menu: items(index) builds the entries for tab index, such as
Close, Close others or Pin. A right click on a tab opens its menu at the pointer; the menu
key or shift+F10 opens the menu of the open tab below it, scrolling the tab into view first.
Choosing an entry sends its message.
Trait Implementations§
Source§impl<Msg: 'static> Widget<Msg> for Tabs<Msg>
impl<Msg: 'static> Widget<Msg> for Tabs<Msg>
Source§fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn paint_overlay(&self, cx: &mut PaintCx<'_>, anchor: Rect)
fn paint_overlay(&self, cx: &mut PaintCx<'_>, anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for Tabs<Msg>
impl<Msg> !Send for Tabs<Msg>
impl<Msg> !Sync for Tabs<Msg>
impl<Msg> !UnwindSafe for Tabs<Msg>
impl<Msg> Freeze for Tabs<Msg>where
TabModel<Msg>: Freeze,
impl<Msg> Unpin for Tabs<Msg>where
TabModel<Msg>: Unpin,
impl<Msg> UnsafeUnpin for Tabs<Msg>where
TabModel<Msg>: 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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more