pub struct ToggleButton { /* private fields */ }Implementations§
Source§impl ToggleButton
impl ToggleButton
Sourcepub fn new(
caption: &str,
tooltip: &str,
layout: Layout,
selected: bool,
button_type: Type,
) -> Self
pub fn new( caption: &str, tooltip: &str, layout: Layout, selected: bool, button_type: Type, ) -> Self
Creates a new toggle button with the specified caption, tooltip, layout, selected state and button type.
The button type can be Normal or Underlined.
§Examples
use appcui::prelude::*;
let mut button = ToggleButton::new("🐼",
"Enable Panda Mode",
layout!("x:1,y:1,w:2"),
false,
togglebutton::Type::Normal);Sourcepub fn with_single_selection(
caption: &str,
tooltip: &str,
layout: Layout,
selected: bool,
button_type: Type,
) -> Self
pub fn with_single_selection( caption: &str, tooltip: &str, layout: Layout, selected: bool, button_type: Type, ) -> Self
Creates a new toggle button with the specified caption, tooltip, layout, selected state and button type.
The button type can be Normal or Underlined.
This type of button is considered to be part of a group of buttons, and only one button can be selected at a time.
Example:
use appcui::prelude::*;
let panda = ToggleButton::with_single_selection("🐼",
"Enable Panda Mode",
layout!("x:1,y:1,w:2"),
false,
togglebutton::Type::Normal);
let dog = ToggleButton::with_single_selection("🐶",
"Enable Dog Mode",
layout!("x:3,y:1,w:2"),
true,
togglebutton::Type::Normal);Sourcepub fn set_caption(&mut self, caption: &str)
pub fn set_caption(&mut self, caption: &str)
Sets the caption of a toggle button.
Sourcepub fn is_selected(&self) -> bool
pub fn is_selected(&self) -> bool
Returns the state of the toggle button (pressed or not)
Sourcepub fn set_selected(&mut self, selected: bool)
pub fn set_selected(&mut self, selected: bool)
Sets the state of the toggle button (pressed or not).
If the button is part of a group of buttons, only one button can be selected at a time. As such, calling this function in this case with a false value will have no effect.
Methods from Deref<Target = ControlBase>§
Sourcepub fn client_size(&self) -> Size
pub fn client_size(&self) -> Size
Returns the client size of a control. In most cases it is the same as the size returned the method .get_size(). However, if the control has margins (for example in case of a Window) this size will be smaller.
Sourcepub fn set_size(&mut self, width: u16, height: u16)
pub fn set_size(&mut self, width: u16, height: u16)
Sets the new size for a control (to a specified size given by parameters width and height). Keep in mind that this method will change the existing layout to an a layout based on top-left corner (given by controls x and y coordonates) and the new provided size. Any dock or alignment properties will be removed.
This method has no effect on a Desktop control.
Sourcepub fn position(&self) -> Point
pub fn position(&self) -> Point
Returns the relatove position (x,y) of the current control to its parent.
Sourcepub fn set_position(&mut self, x: i32, y: i32)
pub fn set_position(&mut self, x: i32, y: i32)
Sets the new position for a control (to a specified coordonate given by parameters x and y). Keep in mind that this method will change the existing layout to an a layout based on top-left corner (given by coordonates x and y) and the controls current width and height. Any dock or alignment properties will be removed.
This method has no effect on a Desktop control.
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Sets the enabled state of a control. This method has no effect on a Desktop or a Window control that will always be enabled.
Sourcepub fn set_visible(&mut self, visible: bool)
pub fn set_visible(&mut self, visible: bool)
Can be used to make a control visible or not. This method has no effect on the Desktop control that will always be visible.
§Examples
use appcui::prelude::*;
let mut button = button!("'Click me',x:1,y:1,w:15");
button.set_visible(false); // this will hide the buttonpub fn set_components_toolbar_margins(&mut self, left: u8, top: u8)
pub fn expanded_size(&self) -> Size
Sourcepub fn request_focus(&mut self) -> bool
pub fn request_focus(&mut self) -> bool
A control can use this method to request focus
pub fn timer(&mut self) -> Option<&mut Timer>
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Returns true if the current control is visible or false otherwise
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true if the current control is enabled or false otherwise
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns true if the current control is active (enabled and visible at the same time) or false otherwise
Sourcepub fn can_receive_input(&self) -> bool
pub fn can_receive_input(&self) -> bool
Returns true if the current control can receive focus or false otherwise. If the control is not visible or it is disable this function will return false.
Sourcepub fn has_focus(&self) -> bool
pub fn has_focus(&self) -> bool
Returns true if the current control has the focus or false otherwise
Sourcepub fn is_mouse_over(&self) -> bool
pub fn is_mouse_over(&self) -> bool
Returns true if the mouse cursor is over the current control or false otherwise
Sourcepub fn set_size_bounds(
&mut self,
min_width: u16,
min_height: u16,
max_width: u16,
max_height: u16,
)
pub fn set_size_bounds( &mut self, min_width: u16, min_height: u16, max_width: u16, max_height: u16, )
Sets the bounds (minim and maxim sized allowed for a control). If the size of a control is outside its bounds, its size will be adjusted automatically. This method has no effect on a Desktop control.
Sourcepub fn set_hotkey<T>(&mut self, hotkey: T)
pub fn set_hotkey<T>(&mut self, hotkey: T)
Sets the hot-key associated with a control. Use Key::None to clear an existing hotkey
pub fn raise_custom_event(&self, class_hash: u64, event_id: u32)
pub fn request_update(&self)
pub fn appbar(&mut self) -> &mut AppBar
pub fn theme(&self) -> &Theme
Sourcepub fn update_layout(&mut self, layout: Layout)
pub fn update_layout(&mut self, layout: Layout)
Updates the layout of the current control
Trait Implementations§
Source§impl AccordionEvents for ToggleButton
impl AccordionEvents for ToggleButton
fn on_panel_changed( &mut self, _handle: Handle<Accordion>, _new_panel_index: u32, _old_panel_index: u32, ) -> EventProcessStatus
Source§impl AppBarEvents for ToggleButton
impl AppBarEvents for ToggleButton
Source§fn on_update(&self, _appbar: &mut AppBar)
fn on_update(&self, _appbar: &mut AppBar)
Source§impl ButtonEvents for ToggleButton
impl ButtonEvents for ToggleButton
fn on_pressed(&mut self, _handle: Handle<Button>) -> EventProcessStatus
Source§impl CharPickerEvents for ToggleButton
impl CharPickerEvents for ToggleButton
fn on_char_changed( &mut self, _handle: Handle<CharPicker>, _code: Option<char>, ) -> EventProcessStatus
Source§impl CheckBoxEvents for ToggleButton
impl CheckBoxEvents for ToggleButton
fn on_status_changed( &mut self, _handle: Handle<CheckBox>, _checked: bool, ) -> EventProcessStatus
Source§impl ColorPickerEvents for ToggleButton
impl ColorPickerEvents for ToggleButton
fn on_color_changed( &mut self, _handle: Handle<ColorPicker>, _color: Color, ) -> EventProcessStatus
Source§impl ComboBoxEvents for ToggleButton
impl ComboBoxEvents for ToggleButton
fn on_selection_changed( &mut self, _handle: Handle<ComboBox>, ) -> EventProcessStatus
impl Control for ToggleButton
Source§impl CustomEvents for ToggleButton
impl CustomEvents for ToggleButton
Source§impl DatePickerEvents for ToggleButton
impl DatePickerEvents for ToggleButton
fn on_date_changed( &mut self, _handle: Handle<DatePicker>, _date: NaiveDate, ) -> EventProcessStatus
Source§impl Deref for ToggleButton
impl Deref for ToggleButton
Source§impl DerefMut for ToggleButton
impl DerefMut for ToggleButton
Source§impl DesktopEvents for ToggleButton
impl DesktopEvents for ToggleButton
Source§impl GenericCommandBarEvents for ToggleButton
impl GenericCommandBarEvents for ToggleButton
fn on_update_commandbar(&self, _commandbar: &mut CommandBar)
fn on_event(&mut self, _command_id: u32)
Source§impl GenericDropDownListEvents for ToggleButton
impl GenericDropDownListEvents for ToggleButton
fn on_selection_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, ) -> EventProcessStatus
Source§impl GenericGraphViewEvents for ToggleButton
impl GenericGraphViewEvents for ToggleButton
fn on_current_node_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, ) -> EventProcessStatus
fn on_node_action( &mut self, _handle: Handle<()>, _type_id: TypeId, _node_index: usize, ) -> EventProcessStatus
fn on_request_new_node( &mut self, _handle: Handle<()>, _type_id: TypeId, _p: Point, ) -> EventProcessStatus
fn on_request_new_edge( &mut self, _handle: Handle<()>, _type_id: TypeId, _from: u32, _to: u32, ) -> EventProcessStatus
fn on_selection_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, ) -> EventProcessStatus
Source§impl GenericListViewEvents for ToggleButton
impl GenericListViewEvents for ToggleButton
fn on_current_item_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, ) -> EventProcessStatus
fn on_group_collapsed( &mut self, _handle: Handle<()>, _type_id: TypeId, _group: Group, ) -> EventProcessStatus
fn on_group_expanded( &mut self, _handle: Handle<()>, _type_id: TypeId, _group: Group, ) -> EventProcessStatus
fn on_selection_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, ) -> EventProcessStatus
fn on_item_action( &mut self, _handle: Handle<()>, _type_id: TypeId, _index: usize, ) -> EventProcessStatus
Source§impl GenericMenuEvents for ToggleButton
impl GenericMenuEvents for ToggleButton
Source§fn on_command(
&mut self,
_menu: Handle<Menu>,
_item: Handle<Command>,
_command: u32,
)
fn on_command( &mut self, _menu: Handle<Menu>, _item: Handle<Command>, _command: u32, )
Source§impl GenericNumericSelectorEvents for ToggleButton
impl GenericNumericSelectorEvents for ToggleButton
fn on_value_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, ) -> EventProcessStatus
Source§impl GenericSelectorEvents for ToggleButton
impl GenericSelectorEvents for ToggleButton
fn on_selection_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, ) -> EventProcessStatus
Source§impl GenericTreeViewEvents for ToggleButton
impl GenericTreeViewEvents for ToggleButton
fn on_current_item_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, _current_item: Handle<()>, ) -> EventProcessStatus
fn on_item_collapsed( &mut self, _handle: Handle<()>, _type_id: TypeId, _item: Handle<()>, _recursive: bool, ) -> EventProcessStatus
fn on_item_expanded( &mut self, _handle: Handle<()>, _type_id: TypeId, _item: Handle<()>, _recursive: bool, ) -> EventProcessStatus
fn on_selection_changed( &mut self, _handle: Handle<()>, _type_id: TypeId, ) -> EventProcessStatus
fn on_item_action( &mut self, _handle: Handle<()>, _type_id: TypeId, _current_item: Handle<()>, ) -> EventProcessStatus
Source§impl KeySelectorEvents for ToggleButton
impl KeySelectorEvents for ToggleButton
fn on_key_changed( &mut self, _handle: Handle<KeySelector>, _new_key: Key, _old_key: Key, ) -> EventProcessStatus
Source§impl ListBoxEvents for ToggleButton
impl ListBoxEvents for ToggleButton
fn on_current_item_changed( &mut self, _handle: Handle<ListBox>, _index: usize, ) -> EventProcessStatus
fn on_item_checked( &mut self, _handle: Handle<ListBox>, _index: usize, _checked: bool, ) -> EventProcessStatus
Source§impl MarkdownEvents for ToggleButton
impl MarkdownEvents for ToggleButton
fn on_external_link( &mut self, _handle: Handle<Markdown>, _link: &str, ) -> EventProcessStatus
impl NotDesktop for ToggleButton
impl NotWindow for ToggleButton
Source§impl OnDefaultAction for ToggleButton
impl OnDefaultAction for ToggleButton
fn on_default_action(&mut self)
Source§impl OnExpand for ToggleButton
impl OnExpand for ToggleButton
Source§impl OnFocus for ToggleButton
impl OnFocus for ToggleButton
Source§impl OnKeyPressed for ToggleButton
impl OnKeyPressed for ToggleButton
fn on_key_pressed(&mut self, key: Key, _character: char) -> EventProcessStatus
Source§impl OnMouseEvent for ToggleButton
impl OnMouseEvent for ToggleButton
fn on_mouse_event(&mut self, event: &MouseEvent) -> EventProcessStatus
Source§impl OnResize for ToggleButton
impl OnResize for ToggleButton
Source§impl OnSiblingSelected for ToggleButton
impl OnSiblingSelected for ToggleButton
fn on_sibling_selected(&mut self, handle: Handle<()>)
Source§impl OnThemeChanged for ToggleButton
impl OnThemeChanged for ToggleButton
fn on_theme_changed(&mut self, _theme: &Theme)
Source§impl OnWindowRegistered for ToggleButton
impl OnWindowRegistered for ToggleButton
fn on_registered(&mut self)
Source§impl PasswordEvents for ToggleButton
impl PasswordEvents for ToggleButton
Source§impl PathFinderEvents for ToggleButton
impl PathFinderEvents for ToggleButton
fn on_path_updated(&mut self, _handle: Handle<PathFinder>) -> EventProcessStatus
Source§impl RadioBoxEvents for ToggleButton
impl RadioBoxEvents for ToggleButton
fn on_selected(&mut self, _handle: Handle<RadioBox>) -> EventProcessStatus
Source§impl RichTextFieldEvents for ToggleButton
impl RichTextFieldEvents for ToggleButton
fn on_validate( &mut self, _handle: Handle<RichTextField>, _text: &str, ) -> EventProcessStatus
fn on_text_changed( &mut self, _handle: Handle<RichTextField>, ) -> EventProcessStatus
Source§impl TabEvents for ToggleButton
impl TabEvents for ToggleButton
fn on_tab_changed( &mut self, _handle: Handle<Tab>, _new_tab_index: u32, _old_tabl_index: u32, ) -> EventProcessStatus
Source§impl TextFieldEvents for ToggleButton
impl TextFieldEvents for ToggleButton
fn on_validate( &mut self, _handle: Handle<TextField>, _text: &str, ) -> EventProcessStatus
fn on_text_changed(&mut self, _handle: Handle<TextField>) -> EventProcessStatus
Source§impl ThreeStateBoxEvents for ToggleButton
impl ThreeStateBoxEvents for ToggleButton
fn on_status_changed( &mut self, _handle: Handle<ThreeStateBox>, _state: State, ) -> EventProcessStatus
Source§impl TimePickerEvents for ToggleButton
impl TimePickerEvents for ToggleButton
fn on_time_changed( &mut self, _handle: Handle<TimePicker>, _time: NaiveTime, ) -> EventProcessStatus
Source§impl TimerEvents for ToggleButton
impl TimerEvents for ToggleButton
fn on_start(&mut self) -> EventProcessStatus
fn on_resume(&mut self, _ticks: u64) -> EventProcessStatus
fn on_pause(&mut self, _ticks: u64) -> EventProcessStatus
fn on_update(&mut self, _ticks: u64) -> EventProcessStatus
Source§impl ToggleButtonEvents for ToggleButton
impl ToggleButtonEvents for ToggleButton
fn on_selection_changed( &mut self, _handle: Handle<ToggleButton>, _selected: bool, ) -> EventProcessStatus
Source§impl ToolBarEvents for ToggleButton
impl ToolBarEvents for ToggleButton
Source§fn on_checkbox_clicked(
&mut self,
_handle: Handle<CheckBox>,
_checked: bool,
) -> EventProcessStatus
fn on_checkbox_clicked( &mut self, _handle: Handle<CheckBox>, _checked: bool, ) -> EventProcessStatus
Source§fn on_choice_selected(
&mut self,
_handle: Handle<SingleChoice>,
) -> EventProcessStatus
fn on_choice_selected( &mut self, _handle: Handle<SingleChoice>, ) -> EventProcessStatus
Source§impl WindowEvents for ToggleButton
impl WindowEvents for ToggleButton
fn on_layout_changed(&mut self, _old_layout: Rect, _new_layout: Rect)
Source§fn on_activate(&mut self)
fn on_activate(&mut self)
Source§fn on_deactivate(&mut self)
fn on_deactivate(&mut self)
Source§fn on_accept(&mut self)
fn on_accept(&mut self)
.exit_with(...) method to exit.
for a regular (non-modal) window this callback is never called)Source§fn on_cancel(&mut self) -> ActionRequest
fn on_cancel(&mut self) -> ActionRequest
Auto Trait Implementations§
impl Freeze for ToggleButton
impl RefUnwindSafe for ToggleButton
impl Send for ToggleButton
impl Sync for ToggleButton
impl Unpin for ToggleButton
impl UnsafeUnpin for ToggleButton
impl UnwindSafe for ToggleButton
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.