pub struct TextCheckbox { /* private fields */ }Expand description
Checkbox that shows a boolean state and swaps state when pressing Spacebar (while focused) Focus highlights the whole Checkbox
Design:
checked: unchecked:
\[x\] Text \[ \] TextImplementations§
Source§impl TextCheckbox
impl TextCheckbox
pub fn default_callback(_: &mut Self)
pub fn set_state_changed_callback<F: Fn(&mut Self) + 'static>( &mut self, callback: F, )
Sourcepub fn set_text(&mut self, text: &str)
pub fn set_text(&mut self, text: &str)
Examples found in repository?
examples/scrollviewer.rs (line 71)
53 fn default() -> Self {
54 let values = [
55 "Tomatoes",
56 "Tofu",
57 "Flatbread",
58 "Olive oil",
59 "Salt",
60 "Oregano",
61 "Butter",
62 ];
63
64 let scrollviewer = WindowFactory::create::<ScrollViewer>();
65 scrollviewer
66 .borrow_mut()
67 .set_border(BorderStyle::new(BorderKind::Solid, None, None));
68 let stackpanel = WindowFactory::create::<Stackpanel>();
69 for v in values {
70 let cbx = WindowFactory::create::<TextCheckbox>();
71 cbx.borrow_mut().set_text(v);
72 stackpanel.borrow_mut().add_item(cbx);
73 }
74 ScrollViewer::set_content(
75 &scrollviewer,
76 Some(&(stackpanel as Rc<RefCell<dyn Scrollable>>)),
77 );
78
79 Self {
80 uid: WindowUID::new(),
81 scrollviewer,
82 running: true,
83 }
84 }pub fn get_state(&self) -> bool
pub fn set_state(&mut self, state: bool)
pub fn set_key_handler(&mut self, f: CheckboxKeyHandler)
Trait Implementations§
Source§impl Default for TextCheckbox
impl Default for TextCheckbox
Source§impl HasWindowUID for TextCheckbox
impl HasWindowUID for TextCheckbox
Source§impl Widget for TextCheckbox
impl Widget for TextCheckbox
fn set_visibility(&mut self, visibility: bool)
fn set_width(&mut self, _: Size)
fn set_height(&mut self, _: Size)
fn set_margin(&mut self, margin: Thickness)
fn set_border(&mut self, border: BorderStyle)
fn set_alignment( &mut self, horizontal: HorizontalAlignment, vertical: VerticalAlignment, )
Source§fn set_enabled_state(&mut self, is_enabled: bool)
fn set_enabled_state(&mut self, is_enabled: bool)
Changing the IsEnabled state usually changes the highlight color
fn set_width_constraint(&mut self, _: SizeConstraint)
fn set_height_constraint(&mut self, _: SizeConstraint)
Source§impl WidgetColors for TextCheckbox
impl WidgetColors for TextCheckbox
fn set_disabled_color(&mut self, color: Option<Color>)
fn set_base_fg_color(&mut self, color: Option<Color>)
fn set_base_bg_color(&mut self, color: Option<Color>)
Source§impl Window for TextCheckbox
impl Window for TextCheckbox
Source§fn handle_event(&mut self, event: &mut WindowEvent)
fn handle_event(&mut self, event: &mut WindowEvent)
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Source§fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
Returns all children windows (and layouting Rects)
Note: When changing the children make sure to also adjust the focus
Source§impl WindowLayout for TextCheckbox
impl WindowLayout for TextCheckbox
Source§fn desired_size(&self, available_size: TPoint) -> TPoint
fn desired_size(&self, available_size: TPoint) -> TPoint
Parents call this to get the desired size of the child
This must not exceed
available_size on any axis
When the result’s product is equal to 0, this window wont be drawnfn border(&self) -> BorderStyle
Source§fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn is_visible(&self) -> bool
fn margin(&self) -> Thickness
Source§fn desired_size_pre_hook(&mut self, available_size: TPoint)
fn desired_size_pre_hook(&mut self, available_size: TPoint)
This is similar to desired_size but will not return anything and can mutably change self
This is executed before WindowLayout::desired_size
Only implement if actually necessary
Auto Trait Implementations§
impl !RefUnwindSafe for TextCheckbox
impl !Send for TextCheckbox
impl !Sync for TextCheckbox
impl !UnwindSafe for TextCheckbox
impl Freeze for TextCheckbox
impl Unpin for TextCheckbox
impl UnsafeUnpin for TextCheckbox
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> Downcast for T
impl<T> Downcast for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> WindowHelper for Twhere
T: Window,
impl<T> WindowHelper for Twhere
T: Window,
Source§fn provoke_changed_property(&self, property: WindowProperty)
fn provoke_changed_property(&self, property: WindowProperty)
Helper method for WindowEventQueue::provoke_changed_property