Skip to main content

RadioMenuButton

Struct RadioMenuButton 

Source
pub struct RadioMenuButton<T: Clone + PartialEq + 'static> {
Show 15 fields pub key: Option<KeyRef>, pub value: T, pub group_value: Option<T>, pub toggleable: bool, pub on_changed: Option<ValueChanged<Option<T>>>, pub on_hover: Option<ValueChanged<bool>>, pub on_focus_change: Option<ValueChanged<bool>>, pub focus_node: Option<FocusNodeRef>, pub shortcut: Option<MenuSerializableShortcutRef>, pub style: Option<ButtonStyle>, pub states_controller: Option<Ref<WidgetStatesController>>, pub clip_behavior: Clip, pub trailing_icon: Option<WidgetRef>, pub close_on_activate: bool, pub child: Option<WidgetRef>,
}
Expand description

A menu item that combines a Radio widget with a MenuItemButton.

To style the radio button separately from the overall button, add a RadioTheme ancestor.

See also:

  • MenuBar, a widget that creates a menu bar of cascading menu items.
  • MenuAnchor, a widget that defines a region which can host a cascading menu.

Fields§

§key: Option<KeyRef>

See Widget::key.

§value: T

The value represented by this radio button.

This radio button is considered selected if its value matches the group_value.

§group_value: Option<T>

The currently selected value for a group of radio buttons.

This radio button is considered selected if its value matches the group_value.

§toggleable: bool

Set to true if this radio button is allowed to be returned to an indeterminate state by selecting it again when selected.

To indicate returning to an indeterminate state, on_changed will be called with null.

If true, on_changed is called with value when selected while group_value != value, and with null when selected again while group_value == value.

If false, on_changed will be called with value when it is selected while group_value != value, and only by selecting another radio button in the group (i.e. changing the value of group_value) can this radio button be unselected.

The default is false.

§on_changed: Option<ValueChanged<Option<T>>>

Called when the user selects this radio button.

The radio button passes value as a parameter to this callback. The radio button does not actually change state until the parent widget rebuilds the radio button with the new group_value.

If null, the radio button will be displayed as disabled.

The provided callback will not be invoked if this radio button is already selected.

§on_hover: Option<ValueChanged<bool>>

Called when a pointer enters or exits the button response area.

The value passed to the callback is true if a pointer has entered button area and false if a pointer has exited.

§on_focus_change: Option<ValueChanged<bool>>

Handler called when the focus changes.

Called with true if this widget’s node gains focus, and false if it loses focus.

§focus_node: Option<FocusNodeRef>

An optional focus node to use as the focus node for this widget.

§shortcut: Option<MenuSerializableShortcutRef>

The optional shortcut that selects this MenuItemButton.

§style: Option<ButtonStyle>

Customizes this button’s appearance.

Non-null properties of this style override the corresponding properties in MenuItemButton::theme_style_of and MenuItemButton::default_style_of. WidgetStatePropertys that resolve to non-null values will similarly override the corresponding WidgetStatePropertys in MenuItemButton::theme_style_of and MenuItemButton::default_style_of.

Null by default.

§states_controller: Option<Ref<WidgetStatesController>>

Represents the interactive “state” of this widget in terms of a set of WidgetStates.

§clip_behavior: Clip

The content will be clipped (or not) according to this option.

Defaults to Clip::None.

§trailing_icon: Option<WidgetRef>

An optional icon to display after the child label.

§close_on_activate: bool

Determines if the menu will be closed when a MenuItemButton is pressed.

Defaults to true.

§child: Option<WidgetRef>

The widget displayed in the center of this button.

Typically this is the button’s label, using a Text widget.

Implementations§

Source§

impl<T: Clone + PartialEq + Debug + 'static> RadioMenuButton<T>

Source

pub fn new<K>( value: T, group_value: Option<T>, on_changed: Option<ValueChanged<Option<T>>>, child: Option<impl IntoWidget<K>>, ) -> RadioMenuButton<T>

Creates a const RadioMenuButton.

The child attribute is required.

Source

pub fn key(self, key: KeyRef) -> RadioMenuButton<T>

Dart RadioMenuButton(key:).

Source

pub fn toggleable(self, toggleable: bool) -> RadioMenuButton<T>

Dart RadioMenuButton(toggleable:).

Source

pub fn on_hover(self, on_hover: ValueChanged<bool>) -> RadioMenuButton<T>

Dart RadioMenuButton(onHover:).

Source

pub fn on_focus_change( self, on_focus_change: ValueChanged<bool>, ) -> RadioMenuButton<T>

Dart RadioMenuButton(onFocusChange:).

Source

pub fn focus_node(self, focus_node: FocusNodeRef) -> RadioMenuButton<T>

Dart RadioMenuButton(focusNode:).

Source

pub fn shortcut( self, shortcut: MenuSerializableShortcutRef, ) -> RadioMenuButton<T>

Dart RadioMenuButton(shortcut:).

Source

pub fn style(self, style: ButtonStyle) -> RadioMenuButton<T>

Dart RadioMenuButton(style:).

Source

pub fn states_controller( self, states_controller: Ref<WidgetStatesController>, ) -> RadioMenuButton<T>

Dart RadioMenuButton(statesController:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> RadioMenuButton<T>

Dart RadioMenuButton(clipBehavior:).

Source

pub fn trailing_icon<K>( self, trailing_icon: impl IntoWidget<K>, ) -> RadioMenuButton<T>

Dart RadioMenuButton(trailingIcon:).

Source

pub fn close_on_activate(self, close_on_activate: bool) -> RadioMenuButton<T>

Dart RadioMenuButton(closeOnActivate:).

Source

pub fn enabled(&self) -> bool

Whether the button is enabled or disabled.

To enable a button, set its on_changed property to a non-null value.

Trait Implementations§

Source§

impl<T: Clone + PartialEq + 'static> Debug for RadioMenuButton<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Clone + PartialEq + Debug + 'static> StatelessWidget for RadioMenuButton<T>

Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef

Describes the part of the user interface represented by this widget. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn debug_check_constructor(&self)

Dart’s constructor asserts that relate two or more arguments. Read more
Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Dart’s this is PreferredSizeWidget: a widget that implements PreferredSizeWidget answers with itself, which is what a parent asking an erased child for its preferred size reads.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for RadioMenuButton<T>

§

impl<T> !Send for RadioMenuButton<T>

§

impl<T> !Sync for RadioMenuButton<T>

§

impl<T> !UnwindSafe for RadioMenuButton<T>

§

impl<T> Forget for RadioMenuButton<T>

§

impl<T> Freeze for RadioMenuButton<T>
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, T: Freeze, *const RcInner<dyn Fn(&mut App, Option<T>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Option<T>)>>: Freeze, *const RcInner<dyn Fn(&mut App, bool)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: Freeze, NonZero<u32>: Freeze, &'static FocusNodeVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn MenuSerializableShortcut> is !null: Freeze, PhantomData<RcInner<dyn MenuSerializableShortcut>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<TextStyle>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<TextStyle>>>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<f64>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<f64>>>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<EdgeInsetsGeometry>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<EdgeInsetsGeometry>>>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<Size>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<Size>>>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<BorderSide>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<BorderSide>>>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<OutlinedBorderRef>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<OutlinedBorderRef>>>>: Freeze, *const RcInner<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>> is !null: Freeze, PhantomData<RcInner<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>>>: Freeze, *const RcInner<dyn InteractiveInkFeatureFactory> is !null: Freeze, PhantomData<RcInner<dyn InteractiveInkFeatureFactory>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, &HashSet<WidgetState>, Option<Rc<dyn Widget>>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, &HashSet<WidgetState>, Option<Rc<dyn Widget>>) -> Rc<dyn Widget>>>: Freeze, *const (): Freeze, PhantomData<fn() -> WidgetStatesController>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl<T> Move for RadioMenuButton<T>

§

impl<T> Unpin for RadioMenuButton<T>

§

impl<T> UnsafeUnpin for RadioMenuButton<T>
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, T: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Option<T>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Option<T>)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, bool)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, &'static FocusNodeVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn MenuSerializableShortcut> is !null: UnsafeUnpin, PhantomData<RcInner<dyn MenuSerializableShortcut>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<TextStyle>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<TextStyle>>>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<f64>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<f64>>>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<EdgeInsetsGeometry>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<EdgeInsetsGeometry>>>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<Size>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<Size>>>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<BorderSide>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<BorderSide>>>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<OutlinedBorderRef>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<OutlinedBorderRef>>>>: UnsafeUnpin, *const RcInner<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>>>: UnsafeUnpin, *const RcInner<dyn InteractiveInkFeatureFactory> is !null: UnsafeUnpin, PhantomData<RcInner<dyn InteractiveInkFeatureFactory>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, &HashSet<WidgetState>, Option<Rc<dyn Widget>>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, &HashSet<WidgetState>, Option<Rc<dyn Widget>>) -> Rc<dyn Widget>>>: UnsafeUnpin, *const (): UnsafeUnpin, PhantomData<fn() -> WidgetStatesController>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatelessKind> for W
where W: StatelessWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>