Skip to main content

Checkbox

Struct Checkbox 

Source
pub struct Checkbox { /* private fields */ }
Expand description

A checkbox widget for boolean selection

Implementations§

Source§

impl Checkbox

Source

pub fn new(label: impl Into<String>) -> Self

Create a new checkbox with a label

Source

pub fn checked(self, checked: bool) -> Self

Set checked state

Source

pub fn style(self, style: CheckboxStyle) -> Self

Set checkbox style

Source

pub fn check_fg(self, color: Color) -> Self

Set checkmark color

Source

pub fn is_checked(&self) -> bool

Check if checkbox is checked

Source

pub fn set_checked(&mut self, checked: bool)

Set checked state (mutable)

Source

pub fn toggle(&mut self)

Toggle checked state

Source

pub fn handle_key(&mut self, key: &Key) -> bool

Handle key input, returns true if state changed

Source§

impl Checkbox

Source

pub fn focused(self, focused: bool) -> Self

Set focused state

Source

pub fn disabled(self, disabled: bool) -> Self

Set disabled state

Source

pub fn fg(self, color: Color) -> Self

Set foreground color

Source

pub fn bg(self, color: Color) -> Self

Set background color

Source

pub fn is_focused(&self) -> bool

Check if widget is focused

Source

pub fn is_disabled(&self) -> bool

Check if widget is disabled

Source

pub fn set_focused(&mut self, focused: bool)

Set focused state (mutable)

Source§

impl Checkbox

Source

pub fn element_id(self, id: impl Into<String>) -> Self

Set element ID for CSS selector (#id)

Source

pub fn class(self, class: impl Into<String>) -> Self

Add a CSS class

Source

pub fn classes<I, S>(self, classes: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add multiple CSS classes

Trait Implementations§

Source§

impl Clone for Checkbox

Source§

fn clone(&self) -> Checkbox

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Checkbox

Source§

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

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

impl Default for Checkbox

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Interactive for Checkbox

Source§

fn handle_key(&mut self, event: &KeyEvent) -> EventResult

Handle keyboard event Read more
Source§

fn focusable(&self) -> bool

Check if the widget can receive focus Read more
Source§

fn on_focus(&mut self)

Called when the widget receives focus Read more
Source§

fn on_blur(&mut self)

Called when the widget loses focus Read more
Source§

fn handle_mouse(&mut self, event: &MouseEvent, area: Rect) -> EventResult

Handle mouse event Read more
Source§

impl StyledView for Checkbox

Source§

fn set_id(&mut self, id: impl Into<String>)

Set element ID
Source§

fn add_class(&mut self, class: impl Into<String>)

Add a CSS class
Source§

fn remove_class(&mut self, class: &str)

Remove a CSS class
Source§

fn toggle_class(&mut self, class: &str)

Toggle a CSS class
Source§

fn has_class(&self, class: &str) -> bool

Check if has class
Source§

impl View for Checkbox

Source§

fn render(&self, ctx: &mut RenderContext<'_>)

Render the view to the given context Read more
Source§

fn id(&self) -> Option<&str>

Get element ID (for CSS #id selectors) Read more
Source§

fn classes(&self) -> &[String]

Get CSS classes (for CSS .class selectors) Read more
Source§

fn meta(&self) -> WidgetMeta

Get widget metadata for DOM Read more
Source§

fn widget_type(&self) -> &'static str

Get widget type name (for CSS type selectors) Read more
Source§

fn children(&self) -> &[Box<dyn View>]

Get child views (for container widgets) Read more

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.