pub struct TabsState { /* private fields */ }Expand description
Retained selection and focus for one tab list and its panels in one window.
The first enabled tab starts selected. Moving focus to another enabled tab
activates it by default, including arrow-key and accessibility/programmatic
focus. Self::manual_activation separates focus movement from activation.
The application keeps panel data in its own retained entities; an inactive
TabPanel contributes no element, focus stop, or accessibility node.
Implementations§
Source§impl TabsState
impl TabsState
pub fn new( items: impl IntoIterator<Item = TabItem>, cx: &mut Context<'_, Self>, ) -> Self
Sourcepub fn manual_activation(self) -> Self
pub fn manual_activation(self) -> Self
Requires a click, Enter, or Space to activate a focused tab.
Set this before the state is first rendered. Arrow keys, Home/End, and programmatic or accessibility focus only move the one Tab entry; they leave the selected panel mounted. Tab re-enters at the last focused tab, initially the selected tab.
Sourcepub fn default_value(self, value: impl AsRef<str>) -> Self
pub fn default_value(self, value: impl AsRef<str>) -> Self
Selects an enabled value before the state is first rendered.
§Panics
Panics if value does not identify an enabled item in this collection.
pub fn items(&self) -> &[TabItem]
pub fn selected_index(&self) -> Option<usize>
pub fn selected_item(&self) -> Option<&TabItem>
Sourcepub fn select_value(
&mut self,
value: impl AsRef<str>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> bool
pub fn select_value( &mut self, value: impl AsRef<str>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
Selects an enabled item without moving keyboard focus.
Returns true when the selection changes. Missing, disabled, and
already-selected values return false without emitting a change.
The caller owns focus when removing the previously selected content.
In manual mode this preserves the last focused tab as the list’s Tab entry.
Sourcepub fn tab_focus_handle(&self, index: usize) -> &FocusHandle
pub fn tab_focus_handle(&self, index: usize) -> &FocusHandle
The stable focus handle of a tab in the fixed collection.
Sourcepub fn panel_focus_handle(&self, index: usize) -> &FocusHandle
pub fn panel_focus_handle(&self, index: usize) -> &FocusHandle
The stable scope handle of a panel. Only the selected panel is rendered.
Trait Implementations§
impl EventEmitter<TabsEvent> for TabsState
Auto Trait Implementations§
impl !RefUnwindSafe for TabsState
impl !Send for TabsState
impl !Sync for TabsState
impl !UnwindSafe for TabsState
impl Forget for TabsState
impl Freeze for TabsState
impl Move for TabsState
impl Unpin for TabsState
impl UnsafeUnpin for TabsState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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