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: boolIf 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: boolTrue 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: ClipThe 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: boolDetermines 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
impl CheckboxMenuButton
Sourcepub fn new<K>(
value: Option<bool>,
on_changed: Option<ValueChanged<Option<bool>>>,
child: Option<impl IntoWidget<K>>,
) -> CheckboxMenuButton
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.
Sourcepub fn key(self, key: KeyRef) -> CheckboxMenuButton
pub fn key(self, key: KeyRef) -> CheckboxMenuButton
Dart CheckboxMenuButton(key:).
Sourcepub fn tristate(self, tristate: bool) -> CheckboxMenuButton
pub fn tristate(self, tristate: bool) -> CheckboxMenuButton
Dart CheckboxMenuButton(tristate:).
Sourcepub fn is_error(self, is_error: bool) -> CheckboxMenuButton
pub fn is_error(self, is_error: bool) -> CheckboxMenuButton
Dart CheckboxMenuButton(isError:).
Sourcepub fn on_hover(self, on_hover: ValueChanged<bool>) -> CheckboxMenuButton
pub fn on_hover(self, on_hover: ValueChanged<bool>) -> CheckboxMenuButton
Dart CheckboxMenuButton(onHover:).
Sourcepub fn on_focus_change(
self,
on_focus_change: ValueChanged<bool>,
) -> CheckboxMenuButton
pub fn on_focus_change( self, on_focus_change: ValueChanged<bool>, ) -> CheckboxMenuButton
Dart CheckboxMenuButton(onFocusChange:).
Sourcepub fn focus_node(self, focus_node: FocusNodeRef) -> CheckboxMenuButton
pub fn focus_node(self, focus_node: FocusNodeRef) -> CheckboxMenuButton
Dart CheckboxMenuButton(focusNode:).
Sourcepub fn shortcut(
self,
shortcut: MenuSerializableShortcutRef,
) -> CheckboxMenuButton
pub fn shortcut( self, shortcut: MenuSerializableShortcutRef, ) -> CheckboxMenuButton
Dart CheckboxMenuButton(shortcut:).
Sourcepub fn style(self, style: ButtonStyle) -> CheckboxMenuButton
pub fn style(self, style: ButtonStyle) -> CheckboxMenuButton
Dart CheckboxMenuButton(style:).
Sourcepub fn states_controller(
self,
states_controller: Ref<WidgetStatesController>,
) -> CheckboxMenuButton
pub fn states_controller( self, states_controller: Ref<WidgetStatesController>, ) -> CheckboxMenuButton
Dart CheckboxMenuButton(statesController:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> CheckboxMenuButton
pub fn clip_behavior(self, clip_behavior: Clip) -> CheckboxMenuButton
Dart CheckboxMenuButton(clipBehavior:).
Sourcepub fn trailing_icon<K>(
self,
trailing_icon: impl IntoWidget<K>,
) -> CheckboxMenuButton
pub fn trailing_icon<K>( self, trailing_icon: impl IntoWidget<K>, ) -> CheckboxMenuButton
Dart CheckboxMenuButton(trailingIcon:).
Sourcepub fn close_on_activate(self, close_on_activate: bool) -> CheckboxMenuButton
pub fn close_on_activate(self, close_on_activate: bool) -> CheckboxMenuButton
Dart CheckboxMenuButton(closeOnActivate:).
Sourcepub fn enabled(&self) -> bool
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
impl Debug for CheckboxMenuButton
Source§impl StatelessWidget for CheckboxMenuButton
impl StatelessWidget for CheckboxMenuButton
Source§fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef
fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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)
fn debug_check_constructor(&self)
Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
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 CheckboxMenuButtonwhere
*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 CheckboxMenuButtonwhere
Rc<dyn Key>: Unpin,
Rc<dyn Fn(&mut App, Option<bool>)>: Unpin,
Rc<dyn Fn(&mut App, bool)>: Unpin,
NonZero<u32>: Unpin,
&'static FocusNodeVTable: Unpin,
Rc<Keep>: Unpin,
Rc<dyn MenuSerializableShortcut>: Unpin,
Rc<dyn WidgetStateProperty<Option<TextStyle>>>: Unpin,
Rc<dyn WidgetStateProperty<Option<Color>>>: Unpin,
Rc<dyn WidgetStateProperty<Option<f64>>>: Unpin,
Rc<dyn WidgetStateProperty<Option<EdgeInsetsGeometry>>>: Unpin,
Rc<dyn WidgetStateProperty<Option<Size>>>: Unpin,
Rc<dyn WidgetStateProperty<Option<BorderSide>>>: Unpin,
Rc<dyn WidgetStateProperty<Option<OutlinedBorderRef>>>: Unpin,
Rc<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>>: Unpin,
Rc<dyn InteractiveInkFeatureFactory>: Unpin,
Rc<dyn Fn(&mut App, AnyElement, &HashSet<WidgetState>, Option<Rc<dyn Widget>>) -> Rc<dyn Widget>>: Unpin,
*const (): Unpin,
Rc<dyn Widget>: Unpin,
impl UnsafeUnpin for CheckboxMenuButtonwhere
*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> 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<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.