pub struct NativeSegmentedView { /* private fields */ }Expand description
A real segmented control rendered from pure Rust — UISegmentedControl on
iOS/iPadOS, NSSegmentedControl on macOS, and a frust-drawn refusal banner
everywhere else (Android included: see [SEGMENTED_ARM]). A
controlled component, like NativeSwitchView: the app owns
selected, and a tap only ever arrives through Self::on_select as a
requested index. Build one with native_segmented.
Implementations§
Source§impl NativeSegmentedView
impl NativeSegmentedView
Sourcepub fn enabled(self, enabled: bool) -> Self
pub fn enabled(self, enabled: bool) -> Self
UIControl.enabled / NSControl.enabled — default true.
Sourcepub fn momentary(self, momentary: bool) -> Self
pub fn momentary(self, momentary: bool) -> Self
Momentary tracking: a tap flashes its segment and reports it through
Self::on_select without leaving it selected (a toolbar of
actions rather than a choice). Default false.
Sourcepub fn content_description(self, label: impl Into<String>) -> Self
pub fn content_description(self, label: impl Into<String>) -> Self
The VoiceOver label.
Sourcepub fn size(self, width: f64, height: f64) -> Self
pub fn size(self, width: f64, height: f64) -> Self
Explicit slot size — see [resolve_size]’s doc for the no-call
fallback.
Sourcepub fn on_select(self, handler: impl Fn(usize) + Send + Sync + 'static) -> Self
pub fn on_select(self, handler: impl Fn(usize) + Send + Sync + 'static) -> Self
Fires with the requested segment index on a user tap — the app
confirms (or rejects) it by feeding selected back through the next
build, the controlled-component contract every interactive frust
widget follows. Never fires on a target with no segmented arm.
Trait Implementations§
Source§impl Clone for NativeSegmentedView
impl Clone for NativeSegmentedView
Source§impl Component for NativeSegmentedView
impl Component for NativeSegmentedView
Source§impl<Outer: 'static> View<Outer> for NativeSegmentedView
impl<Outer: 'static> View<Outer> for NativeSegmentedView
Source§type Element = ComponentWidget<NativeSegmentedView>
type Element = ComponentWidget<NativeSegmentedView>
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> Self::Element
fn build(&self, ctx: &mut BuildCtx<'_>) -> Self::Element
Source§fn rebuild(
&self,
prev: &Self,
element: &mut Self::Element,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut Self::Element, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.Auto Trait Implementations§
impl !RefUnwindSafe for NativeSegmentedView
impl !UnwindSafe for NativeSegmentedView
impl Freeze for NativeSegmentedView
impl Send for NativeSegmentedView
impl Sync for NativeSegmentedView
impl Unpin for NativeSegmentedView
impl UnsafeUnpin for NativeSegmentedView
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.