pub struct AccordionState { /* private fields */ }Expand description
Retained state for one accordion in one window.
All items start collapsed. Every enabled header is a Tab stop; moving focus with Up, Down, Home, or End never changes the open items. The application keeps panel data in its own retained entities, independently of panel mounting.
Implementations§
Source§impl AccordionState
impl AccordionState
pub fn new( items: impl IntoIterator<Item = AccordionItem>, cx: &mut Context<'_, Self>, ) -> Self
Sourcepub fn multiple(self, multiple: bool) -> Self
pub fn multiple(self, multiple: bool) -> Self
Allows several panels to remain open, defaulting to false. Configure this before setting multiple default values or rendering the state.
§Panics
Panics when disabling multiple mode with several default panels open.
Sourcepub fn default_open<V: AsRef<str>>(
self,
values: impl IntoIterator<Item = V>,
) -> Self
pub fn default_open<V: AsRef<str>>( self, values: impl IntoIterator<Item = V>, ) -> Self
Opens enabled values before the state is first rendered, without emitting an event.
Set Self::multiple to true before supplying several values.
§Panics
Every value must identify an enabled item in this collection. Single-open mode accepts at most one distinct value.
pub fn items(&self) -> &[AccordionItem]
pub fn is_open(&self, index: usize) -> bool
Sourcepub fn open_values(&self) -> Vec<SharedString>
pub fn open_values(&self) -> Vec<SharedString>
The open values in their original item order.
Sourcepub fn trigger_focus_handle(&self, index: usize) -> &FocusHandle
pub fn trigger_focus_handle(&self, index: usize) -> &FocusHandle
The stable focus handle of a header’s native button.
Sourcepub fn panel_focus_handle(&self, index: usize) -> &FocusHandle
pub fn panel_focus_handle(&self, index: usize) -> &FocusHandle
The stable focus scope of a panel, mounted only while that item is open.
Sourcepub fn toggle(
&mut self,
index: usize,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn toggle( &mut self, index: usize, window: &mut Window, cx: &mut Context<'_, Self>, )
Opens a closed item or collapses an open item. In single-open mode, opening
another item closes the previous panel; multiple mode leaves other panels open.
Disabled items ignore requests. index must identify an item.
If this removes the focused panel, focus moves to the requested header. Focus elsewhere is preserved, including a header already focused by a click.
Sourcepub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Collapses all open panels and returns focused panel content to its header. Focus outside the panels is preserved. Removing the whole accordion remains the application’s responsibility, including its choice of focus target.
Trait Implementations§
impl EventEmitter<AccordionEvent> for AccordionState
Auto Trait Implementations§
impl !RefUnwindSafe for AccordionState
impl !UnwindSafe for AccordionState
impl Forget for AccordionState
impl Freeze for AccordionState
impl Move for AccordionState
impl Send for AccordionState
impl Sync for AccordionState
impl Unpin for AccordionState
impl UnsafeUnpin for AccordionState
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