pub struct ToggleButton { /* private fields */ }
Expand description
A toggle button
Implementations§
Source§impl ToggleButton
impl ToggleButton
pub fn new(state: impl Fn() -> bool + 'static) -> Self
pub fn new_rw( state: impl SignalGet<bool> + SignalUpdate<bool> + Copy + 'static, ) -> Self
Sourcepub fn on_toggle(self, ontoggle: impl Fn(bool) + 'static) -> Self
pub fn on_toggle(self, ontoggle: impl Fn(bool) + 'static) -> Self
Add an event handler to be run when the button is toggled.
This does not run if the state is changed because of an outside signal. This handler is only called if this button is clicked or switched
pub fn toggle_style( self, style: impl Fn(ToggleButtonCustomStyle) -> ToggleButtonCustomStyle + 'static, ) -> Self
Trait Implementations§
Source§impl View for ToggleButton
impl View for ToggleButton
fn id(&self) -> ViewId
fn debug_name(&self) -> Cow<'static, str>
Source§fn update(&mut self, _cx: &mut UpdateCx<'_>, state: Box<dyn Any>)
fn update(&mut self, _cx: &mut UpdateCx<'_>, state: Box<dyn Any>)
Use this method to react to changes in view-related state.
You will usually send state to this hook manually using the
View
’s Id
handle Read morefn event_before_children( &mut self, cx: &mut EventCx<'_>, event: &Event, ) -> EventPropagation
Source§fn compute_layout(&mut self, _cx: &mut ComputeLayoutCx<'_>) -> Option<Rect>
fn compute_layout(&mut self, _cx: &mut ComputeLayoutCx<'_>) -> Option<Rect>
Responsible for computing the layout of the view’s children. Read more
Source§fn style_pass(&mut self, cx: &mut StyleCx<'_>)
fn style_pass(&mut self, cx: &mut StyleCx<'_>)
Use this method to style the view’s children. Read more
Source§fn paint(&mut self, cx: &mut PaintCx<'_>)
fn paint(&mut self, cx: &mut PaintCx<'_>)
View
-specific implementation. Will be called in PaintCx::paint_view
.
Usually you’ll call paint_view
for every child view. But you might also draw text, adjust the offset, clip
or draw text.fn view_style(&self) -> Option<Style>
fn view_class(&self) -> Option<StyleClassRef>
Source§fn layout(&mut self, cx: &mut LayoutCx<'_>) -> NodeId
fn layout(&mut self, cx: &mut LayoutCx<'_>) -> NodeId
Use this method to layout the view’s children.
Usually you’ll do this by calling
LayoutCx::layout_node
. Read morefn event_after_children( &mut self, cx: &mut EventCx<'_>, event: &Event, ) -> EventPropagation
Auto Trait Implementations§
impl Freeze for ToggleButton
impl !RefUnwindSafe for ToggleButton
impl !Send for ToggleButton
impl !Sync for ToggleButton
impl Unpin for ToggleButton
impl !UnwindSafe for ToggleButton
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
Mutably borrows from an owned value. Read more
Source§impl<T> ContainerExt for Twhere
T: IntoView + 'static,
impl<T> ContainerExt for Twhere
T: IntoView + 'static,
Source§impl<VW, IV> Decorators for IV
impl<VW, IV> Decorators for IV
Source§fn style(self, style: impl Fn(Style) -> Style + 'static) -> Self::DV
fn style(self, style: impl Fn(Style) -> Style + 'static) -> Self::DV
Alter the style of the view. Read more
Source§fn debug_name(self, name: impl Into<String>) -> Self::DV
fn debug_name(self, name: impl Into<String>) -> Self::DV
Add a debug name to the view that will be shown in the inspector. Read more
Source§fn debug_name_if<S: Into<String>>(
self,
apply: impl Fn() -> bool + 'static,
name: impl Fn() -> S + 'static,
) -> Self::DV
fn debug_name_if<S: Into<String>>( self, apply: impl Fn() -> bool + 'static, name: impl Fn() -> S + 'static, ) -> Self::DV
Conditionally add a debug name to the view that will be shown in the inspector. Read more
Source§fn dragging_style(self, style: impl Fn(Style) -> Style + 'static) -> Self::DV
fn dragging_style(self, style: impl Fn(Style) -> Style + 'static) -> Self::DV
The visual style to apply when the mouse hovers over the element
Source§fn class<C: StyleClass>(self, _class: C) -> Self::DV
fn class<C: StyleClass>(self, _class: C) -> Self::DV
Add a style class to the view
Source§fn class_if<C: StyleClass>(
self,
apply: impl Fn() -> bool + 'static,
_class: C,
) -> Self::DV
fn class_if<C: StyleClass>( self, apply: impl Fn() -> bool + 'static, _class: C, ) -> Self::DV
Conditionally add a style class to the view
Source§fn remove_class<C: StyleClass>(self, _class: C) -> Self::DV
fn remove_class<C: StyleClass>(self, _class: C) -> Self::DV
Remove a style class from the view
Allows the element to be navigated to with the keyboard. Similar to setting tabindex=“0” in html.
Source§fn disable_default_event(
self,
disable: impl Fn() -> (EventListener, bool) + 'static,
) -> Self::DV
fn disable_default_event( self, disable: impl Fn() -> (EventListener, bool) + 'static, ) -> Self::DV
Dynamically controls whether the default view behavior for an event should be disabled.
When disable is true, children will still see the event, but the view event function will not be called nor
the event listeners on the view. Read more
Source§fn disabled(self, disabled_fn: impl Fn() -> bool + 'static) -> Self::DV
fn disabled(self, disabled_fn: impl Fn() -> bool + 'static) -> Self::DV
Mark the view as disabled Read more
Source§fn on_event(
self,
listener: EventListener,
action: impl FnMut(&Event) -> EventPropagation + 'static,
) -> Self::DV
fn on_event( self, listener: EventListener, action: impl FnMut(&Event) -> EventPropagation + 'static, ) -> Self::DV
Add an event handler for the given EventListener.
Source§fn on_key_down(
self,
key: Key,
cmp: impl Fn(Modifiers) -> bool + 'static,
action: impl Fn(&Event) + 'static,
) -> Self::DV
fn on_key_down( self, key: Key, cmp: impl Fn(Modifiers) -> bool + 'static, action: impl Fn(&Event) + 'static, ) -> Self::DV
Add an handler for pressing down a specific key. Read more
Source§fn on_key_up(
self,
key: Key,
cmp: impl Fn(Modifiers) -> bool + 'static,
action: impl Fn(&Event) + 'static,
) -> Self::DV
fn on_key_up( self, key: Key, cmp: impl Fn(Modifiers) -> bool + 'static, action: impl Fn(&Event) + 'static, ) -> Self::DV
Add an handler for a specific key being released. Read more
Source§fn on_event_cont(
self,
listener: EventListener,
action: impl Fn(&Event) + 'static,
) -> Self::DV
fn on_event_cont( self, listener: EventListener, action: impl Fn(&Event) + 'static, ) -> Self::DV
Add an event handler for the given EventListener. This event will be handled with
the given handler and the event will continue propagating.
Source§fn on_event_stop(
self,
listener: EventListener,
action: impl Fn(&Event) + 'static,
) -> Self::DV
fn on_event_stop( self, listener: EventListener, action: impl Fn(&Event) + 'static, ) -> Self::DV
Add an event handler for the given EventListener. This event will be handled with
the given handler and the event will stop propagating.
Source§fn on_click(
self,
action: impl FnMut(&Event) -> EventPropagation + 'static,
) -> Self::DV
fn on_click( self, action: impl FnMut(&Event) -> EventPropagation + 'static, ) -> Self::DV
Add an event handler for EventListener::Click.
Source§fn on_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::DV
fn on_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::DV
Add an event handler for EventListener::Click. This event will be handled with
the given handler and the event will continue propagating.
Source§fn on_click_stop(self, action: impl FnMut(&Event) + 'static) -> Self::DV
fn on_click_stop(self, action: impl FnMut(&Event) + 'static) -> Self::DV
Add an event handler for EventListener::Click. This event will be handled with
the given handler and the event will stop propagating.
Source§fn on_double_click(
self,
action: impl Fn(&Event) -> EventPropagation + 'static,
) -> Self::DV
fn on_double_click( self, action: impl Fn(&Event) -> EventPropagation + 'static, ) -> Self::DV
Add an event handler for EventListener::DoubleClick
Source§fn on_double_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::DV
fn on_double_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::DV
Add an event handler for EventListener::DoubleClick. This event will be handled with
the given handler and the event will continue propagating.
Source§fn on_double_click_stop(self, action: impl Fn(&Event) + 'static) -> Self::DV
fn on_double_click_stop(self, action: impl Fn(&Event) + 'static) -> Self::DV
Add an event handler for EventListener::DoubleClick. This event will be handled with
the given handler and the event will stop propagating.
Source§fn on_secondary_click(
self,
action: impl Fn(&Event) -> EventPropagation + 'static,
) -> Self::DV
fn on_secondary_click( self, action: impl Fn(&Event) -> EventPropagation + 'static, ) -> Self::DV
Add an event handler for EventListener::SecondaryClick. This is most often the “Right” click.
Source§fn on_secondary_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::DV
fn on_secondary_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::DV
Add an event handler for EventListener::SecondaryClick. This is most often the “Right” click.
This event will be handled with the given handler and the event will continue propagating.
Source§fn on_secondary_click_stop(self, action: impl Fn(&Event) + 'static) -> Self::DV
fn on_secondary_click_stop(self, action: impl Fn(&Event) + 'static) -> Self::DV
Add an event handler for EventListener::SecondaryClick. This is most often the “Right” click.
This event will be handled with the given handler and the event will stop propagating.
Source§fn on_resize(self, action: impl Fn(Rect) + 'static) -> Self::DV
fn on_resize(self, action: impl Fn(Rect) + 'static) -> Self::DV
Set the event handler for resize events for this view. Read more
Source§fn on_move(self, action: impl Fn(Point) + 'static) -> Self::DV
fn on_move(self, action: impl Fn(Point) + 'static) -> Self::DV
Set the event handler for move events for this view. Read more
Source§fn on_cleanup(self, action: impl Fn() + 'static) -> Self::DV
fn on_cleanup(self, action: impl Fn() + 'static) -> Self::DV
Set the event handler for cleanup events for this view. Read more
Source§fn animation(
self,
animation: impl Fn(Animation) -> Animation + 'static,
) -> Self::DV
fn animation( self, animation: impl Fn(Animation) -> Animation + 'static, ) -> Self::DV
Add an animation to the view. Read more
Source§fn clear_focus(self, when: impl Fn() + 'static) -> Self::DV
fn clear_focus(self, when: impl Fn() + 'static) -> Self::DV
Clear the focus from the window. Read more
Source§fn request_focus(self, when: impl Fn() + 'static) -> Self::DV
fn request_focus(self, when: impl Fn() + 'static) -> Self::DV
Request that this view gets the focus for the window. Read more
Source§fn window_scale(self, scale_fn: impl Fn() -> f64 + 'static) -> Self
fn window_scale(self, scale_fn: impl Fn() -> f64 + 'static) -> Self
Set the window scale factor. Read more
Source§fn window_title(self, title_fn: impl Fn() -> String + 'static) -> Self
fn window_title(self, title_fn: impl Fn() -> String + 'static) -> Self
Set the window title. Read more
Set the system window menu Read more
Adds a secondary-click context menu to the view, which opens at the mouse position. Read more
Adds a primary-click context menu, which opens below the view. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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