pub struct Checkbox { /* private fields */ }Expand description
A checkbox widget with a label and toggleable state.
Press Space or Enter to toggle. Renders as [✓] label when checked
and [ ] label when unchecked.
Implementations§
Source§impl Checkbox
impl Checkbox
Sourcepub fn new(label: impl Into<Text>) -> Self
pub fn new(label: impl Into<Text>) -> Self
Creates a new unchecked checkbox with the given label.
Sourcepub fn checked_style(self, style: Style) -> Self
pub fn checked_style(self, style: Style) -> Self
Builder: sets the checked-state style.
Sourcepub fn is_checked(&self) -> bool
pub fn is_checked(&self) -> bool
Returns whether the checkbox is currently checked.
Sourcepub fn set_checked(&mut self, checked: bool, cx: &mut EventCx<'_>)
pub fn set_checked(&mut self, checked: bool, cx: &mut EventCx<'_>)
Sets the checked state.
Trait Implementations§
Source§impl Component for Checkbox
impl Component for Checkbox
Source§fn measure(&self, _constraint: Constraint, _cx: &mut MeasureCx) -> Size
fn measure(&self, _constraint: Constraint, _cx: &mut MeasureCx) -> Size
测量组件在给定约束下的自适应尺寸 Read more
Source§fn layout(&mut self, rect: Rect, _cx: &mut LayoutCx<'_>)
fn layout(&mut self, rect: Rect, _cx: &mut LayoutCx<'_>)
布局回调——组件在此计算子节点 rect 并调用 child.layout() Read more
Source§fn for_each_child(&self, _f: &mut dyn FnMut(&Node))
fn for_each_child(&self, _f: &mut dyn FnMut(&Node))
遍历子节点(为焦点系统等提供统一的树遍历接口)
Source§fn for_each_child_mut(&mut self, _f: &mut dyn FnMut(&mut Node))
fn for_each_child_mut(&mut self, _f: &mut dyn FnMut(&mut Node))
遍历子节点(可变版本)
Auto Trait Implementations§
impl Freeze for Checkbox
impl RefUnwindSafe for Checkbox
impl Send for Checkbox
impl Sync for Checkbox
impl Unpin for Checkbox
impl UnsafeUnpin for Checkbox
impl UnwindSafe for Checkbox
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