pub struct Checkbox;Expand description
A toggleable checkbox component.
This component provides a boolean input that can be toggled via
keyboard when focused. The checkbox emits a CheckboxOutput::Toggled
message containing the new state when toggled.
§Keyboard Activation
The checkbox itself doesn’t handle keyboard events directly. Your
application should map Enter/Space keys to CheckboxMessage::Toggle
when the checkbox is focused.
§Visual States
- Unchecked:
[ ] Label - Checked:
[x] Label - Focused: Yellow text
- Disabled: Dark gray text, doesn’t respond to toggle
§Example
use envision::component::{Checkbox, CheckboxMessage, CheckboxOutput, CheckboxState, Component};
let mut state = CheckboxState::new("Dark mode");
// Toggle the checkbox
let output = Checkbox::update(&mut state, CheckboxMessage::Toggle);
assert_eq!(output, Some(CheckboxOutput::Toggled(true)));
assert!(state.is_checked());Trait Implementations§
Source§impl Component for Checkbox
impl Component for Checkbox
Source§type State = CheckboxState
type State = CheckboxState
The component’s internal state type. Read more
Source§type Message = CheckboxMessage
type Message = CheckboxMessage
Messages this component can receive. Read more
Source§type Output = CheckboxOutput
type Output = CheckboxOutput
Messages this component can emit to its parent. Read more
Auto Trait Implementations§
impl Freeze for Checkbox
impl RefUnwindSafe for Checkbox
impl Send for Checkbox
impl Sync for Checkbox
impl Unpin 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more