Skip to main content

CheckboxMenuButton

Struct CheckboxMenuButton 

Source
pub struct CheckboxMenuButton {
Show 15 fields pub key: Option<KeyRef>, pub value: Option<bool>, pub tristate: bool, pub is_error: bool, pub on_changed: Option<ValueChanged<Option<bool>>>, 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 Checkbox widget with a MenuItemButton.

To style the checkbox separately from the button, add a CheckboxTheme 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: Option<bool>

Whether this checkbox is checked.

When tristate is true, a value of null corresponds to the mixed state. When tristate is false, this value must not be null.

§tristate: bool

If true, then the checkbox’s value can be true, false, or null.

CheckboxMenuButton displays a dash when its value is null.

When a tri-state checkbox (tristate is true) is tapped, its on_changed callback will be applied to true if the current value is false, to null if value is true, and to false if value is null (i.e. it cycles through false => true => null => false when tapped).

If tristate is false (the default), value must not be null.

§is_error: bool

True if this checkbox wants to show an error state.

The checkbox will have different default container color and check color when this is true. This is only used when ThemeData::use_material3 is set to true.

Defaults to false.

§on_changed: Option<ValueChanged<Option<bool>>>

Called when the value of the checkbox should change.

The checkbox passes the new value to the callback but does not actually change state until the parent widget rebuilds the checkbox with the new value.

If this callback is null, the menu item will be displayed as disabled and will not respond to input gestures.

When the checkbox is tapped, if tristate is false (the default) then the on_changed callback will be applied to !value. If tristate is true this callback cycle from false to true to null and then back to false again.

§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 CheckboxMenuButton

Source

pub fn new<K>( value: Option<bool>, on_changed: Option<ValueChanged<Option<bool>>>, child: Option<impl IntoWidget<K>>, ) -> CheckboxMenuButton

Creates a const CheckboxMenuButton.

The child, value, and on_changed attributes are required.

Source

pub fn key(self, key: KeyRef) -> CheckboxMenuButton

Dart CheckboxMenuButton(key:).

Source

pub fn tristate(self, tristate: bool) -> CheckboxMenuButton

Dart CheckboxMenuButton(tristate:).

Source

pub fn is_error(self, is_error: bool) -> CheckboxMenuButton

Dart CheckboxMenuButton(isError:).

Source

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

Dart CheckboxMenuButton(onHover:).

Source

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

Dart CheckboxMenuButton(onFocusChange:).

Source

pub fn focus_node(self, focus_node: FocusNodeRef) -> CheckboxMenuButton

Dart CheckboxMenuButton(focusNode:).

Source

pub fn shortcut( self, shortcut: MenuSerializableShortcutRef, ) -> CheckboxMenuButton

Dart CheckboxMenuButton(shortcut:).

Source

pub fn style(self, style: ButtonStyle) -> CheckboxMenuButton

Dart CheckboxMenuButton(style:).

Source

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

Dart CheckboxMenuButton(statesController:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> CheckboxMenuButton

Dart CheckboxMenuButton(clipBehavior:).

Source

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

Dart CheckboxMenuButton(trailingIcon:).

Source

pub fn close_on_activate(self, close_on_activate: bool) -> CheckboxMenuButton

Dart CheckboxMenuButton(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 Debug for CheckboxMenuButton

Source§

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

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

impl StatelessWidget for CheckboxMenuButton

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 !RefUnwindSafe for CheckboxMenuButton

§

impl !Send for CheckboxMenuButton

§

impl !Sync for CheckboxMenuButton

§

impl !UnwindSafe for CheckboxMenuButton

§

impl Forget for CheckboxMenuButton

§

impl Freeze for CheckboxMenuButton
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Fn(&mut App, Option<bool>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Option<bool>)>>: 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 Move for CheckboxMenuButton

§

impl Unpin for CheckboxMenuButton

§

impl UnsafeUnpin for CheckboxMenuButton
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Option<bool>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Option<bool>)>>: 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>