pub struct SelectData { /* private fields */ }Expand description
The selectedness of a <select> element’s list of options, plus whether its
drop-down is showing.
Positions, not node ids. selectedIndex is the spec’s own handle on an
option, and a position cannot dangle the way a stored id does once the
option is removed from the tree. The list of options itself is recomputed
from the subtree on every read, so a stale position is at worst out of
range rather than pointing at some unrelated node.
A Vec<bool> rather than a single index because <select multiple> can
have any number of options selected at once, and a single index would make
the multiple case unrepresentable rather than merely unsupported.
Implementations§
Source§impl SelectData
impl SelectData
Sourcepub fn new(selected: Vec<bool>) -> Self
pub fn new(selected: Vec<bool>) -> Self
Seed the state with one entry per option, in the select’s list order.
Sourcepub fn resize(&mut self, len: usize)
pub fn resize(&mut self, len: usize)
Grow or shrink to len options, keeping the selectedness of the options
that are still there.
Layout construction runs again on every resolve, so this is the only
place a script-added <option> gets an entry of its own. Re-seeding
from the selected content attributes instead would throw away whatever
the user had actually chosen the moment anything else on the page
changed.
pub fn is_empty(&self) -> bool
Sourcepub fn is_selected(&self, index: usize) -> bool
pub fn is_selected(&self, index: usize) -> bool
Whether the option at index is selected. Out of range reads false.
Sourcepub fn selected_index(&self) -> Option<usize>
pub fn selected_index(&self) -> Option<usize>
The first selected option, which is selectedIndex for a single select.
Sourcepub fn set_selected(&mut self, index: usize, selected: bool) -> bool
pub fn set_selected(&mut self, index: usize, selected: bool) -> bool
Set one option’s selectedness without touching the others. Returns whether it changed.
Sourcepub fn select_only(&mut self, index: usize) -> bool
pub fn select_only(&mut self, index: usize) -> bool
Select index and clear every other option. Returns whether anything
changed.
Sourcepub fn clear_selection(&mut self) -> bool
pub fn clear_selection(&mut self) -> bool
Deselect every option. Returns whether anything changed.
pub fn set_open(&mut self, open: bool)
Trait Implementations§
Source§impl Clone for SelectData
impl Clone for SelectData
Source§impl Debug for SelectData
impl Debug for SelectData
Source§impl Default for SelectData
impl Default for SelectData
impl Eq for SelectData
Source§impl PartialEq for SelectData
impl PartialEq for SelectData
impl StructuralPartialEq for SelectData
Auto Trait Implementations§
impl Freeze for SelectData
impl RefUnwindSafe for SelectData
impl Send for SelectData
impl Sync for SelectData
impl Unpin for SelectData
impl UnsafeUnpin for SelectData
impl UnwindSafe for SelectData
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<T> Brush for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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