Struct kas_widgets::RadioButton
source · pub struct RadioButton { /* private fields */ }
Expand description
A radio button with label
See also RadioBox
which excludes the label.
Implementations§
source§impl RadioButton
impl RadioButton
sourcepub fn new<T: Into<AccelString>>(label: T, group: RadioGroup) -> Self
pub fn new<T: Into<AccelString>>(label: T, group: RadioGroup) -> Self
Construct a radio button with a given label
and group
RadioButton labels are optional; if no label is desired, use an empty
string or use RadioBox
instead.
All instances of RadioBox
and RadioButton
constructed over the
same group
will be considered part of a single group.
sourcepub fn on_select<F>(self, f: F) -> RadioButtonwhere
F: Fn(&mut EventMgr<'_>) + 'static,
pub fn on_select<F>(self, f: F) -> RadioButtonwhere F: Fn(&mut EventMgr<'_>) + 'static,
Set event handler f
When the radio button is selected, the closure f
is called.
No handler is called on deselection.
sourcepub fn new_on<T: Into<AccelString>, F>(label: T, group: RadioGroup, f: F) -> Selfwhere
F: Fn(&mut EventMgr<'_>) + 'static,
pub fn new_on<T: Into<AccelString>, F>(label: T, group: RadioGroup, f: F) -> Selfwhere F: Fn(&mut EventMgr<'_>) + 'static,
Construct a radio button with given label
, group
and event handler f
RadioButton labels are optional; if no label is desired, use an empty string.
All instances of RadioBox
and RadioButton
constructed over the
same group
will be considered part of a single group.
When the radio button is selected, the closure f
is called.
No handler is called on deselection.
sourcepub fn new_msg<S, M>(label: S, group: RadioGroup, msg: M) -> Selfwhere
S: Into<AccelString>,
M: Clone + Debug + 'static,
pub fn new_msg<S, M>(label: S, group: RadioGroup, msg: M) -> Selfwhere S: Into<AccelString>, M: Clone + Debug + 'static,
Construct a radio button with given label
, group
and payload msg
RadioButton labels are optional; if no label is desired, use an empty string.
All instances of RadioBox
and RadioButton
constructed over the
same group
will be considered part of a single group.
When the radio button is selected, a clone
of msg
is returned to the parent widget via EventMgr::push
.
No handler is called on deselection.
sourcepub fn with_state(self, state: bool) -> Self
pub fn with_state(self, state: bool) -> Self
Set the initial state of the radio button.
sourcepub fn select(&mut self, mgr: &mut EventMgr<'_>) -> bool
pub fn select(&mut self, mgr: &mut EventMgr<'_>) -> bool
Select this radio box from the group
This radio box will be set true while all others from the group will be set false. Returns true if newly selected, false if already selected.
This does not call the event handler set by Self::on_select
or Self::new_on
.
Trait Implementations§
source§impl AutoLayout for RadioButton
impl AutoLayout for RadioButton
source§impl Clone for RadioButton
impl Clone for RadioButton
source§fn clone(&self) -> RadioButton
fn clone(&self) -> RadioButton
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RadioButton
impl Debug for RadioButton
source§impl HasBool for RadioButton
impl HasBool for RadioButton
source§impl Layout for RadioButton
impl Layout for RadioButton
source§impl Widget for RadioButton
impl Widget for RadioButton
source§fn translation(&self) -> Offset
fn translation(&self) -> Offset
source§fn steal_event(
&mut self,
mgr: &mut EventMgr<'_>,
id: &WidgetId,
event: &Event
) -> Response
fn steal_event( &mut self, mgr: &mut EventMgr<'_>, id: &WidgetId, event: &Event ) -> Response
source§fn handle_unused(&mut self, mgr: &mut EventMgr<'_>, event: Event) -> Response
fn handle_unused(&mut self, mgr: &mut EventMgr<'_>, event: Event) -> Response
index
but left unhandled Read moresource§fn handle_message(&mut self, mgr: &mut EventMgr<'_>)
fn handle_message(&mut self, mgr: &mut EventMgr<'_>)
source§impl WidgetChildren for RadioButton
impl WidgetChildren for RadioButton
source§fn num_children(&self) -> usize
fn num_children(&self) -> usize
source§fn get_child(&self, _index: usize) -> Option<&dyn Widget>
fn get_child(&self, _index: usize) -> Option<&dyn Widget>
None
if the index is
out of bounds. Read moresource§fn get_child_mut(&mut self, _index: usize) -> Option<&mut dyn Widget>
fn get_child_mut(&mut self, _index: usize) -> Option<&mut dyn Widget>
source§impl WidgetCore for RadioButton
impl WidgetCore for RadioButton
source§fn widget_name(&self) -> &'static str
fn widget_name(&self) -> &'static str
source§fn as_widget_mut(&mut self) -> &mut dyn Widget
fn as_widget_mut(&mut self) -> &mut dyn Widget
Auto Trait Implementations§
impl !RefUnwindSafe for RadioButton
impl !Send for RadioButton
impl !Sync for RadioButton
impl Unpin for RadioButton
impl !UnwindSafe for RadioButton
Blanket Implementations§
§impl<S, T> Cast<T> for Swhere
T: Conv<S>,
impl<S, T> Cast<T> for Swhere T: Conv<S>,
§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere T: ConvApprox<S>,
§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
§fn cast_approx(self) -> T
fn cast_approx(self) -> T
§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere T: ConvFloat<S>,
§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
§fn cast_floor(self) -> T
fn cast_floor(self) -> T
§fn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
§fn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
§fn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
§fn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
source§impl<W> WidgetExt for Wwhere
W: Widget + ?Sized,
impl<W> WidgetExt for Wwhere W: Widget + ?Sized,
source§fn eq_id<T>(&self, rhs: T) -> boolwhere
WidgetId: PartialEq<T>,
fn eq_id<T>(&self, rhs: T) -> boolwhere WidgetId: PartialEq<T>,
source§fn identify(&self) -> IdentifyWidget
fn identify(&self) -> IdentifyWidget
source§fn is_ancestor_of(&self, id: &WidgetId) -> bool
fn is_ancestor_of(&self, id: &WidgetId) -> bool
id
is self or a descendant Read moresource§fn is_strict_ancestor_of(&self, id: &WidgetId) -> bool
fn is_strict_ancestor_of(&self, id: &WidgetId) -> bool
id
is not self and is a descendant Read more