pub enum CheckMenuKind<G> {
CheckBox(Rc<CheckMenuItem>, G),
Radio(Rc<CheckMenuItem>, Option<Rc<MenuId>>, G),
Separate(Rc<CheckMenuItem>),
}Expand description
Represents different types of checkable menu items with their associated data
This enum defines three types of checkable menu items:
§Variants
§CheckBox
- Contains:
Rc<CheckMenuItem>and group identifierG - Purpose: A standard checkbox that can be checked/unchecked independently
- Grouping: Items with the same
Gvalue belong to the same logical group
§Radio
- Contains:
Rc<CheckMenuItem>, optional defaultMenuId, and group identifierG - Purpose: A radio button where only one item in the same group can be selected
- Default ID:
IfSome, specifies which menu should be selected when all radios in the group are unchecked.
IfNone, no action is taken when all radios are unchecked. - Grouping: All radio buttons with the same
Gvalue form a single selection group
§Separate
- Contains:
Rc<CheckMenuItem>only - Purpose: A standalone checkbox with no grouping requirements
- Use case: For independent toggle options that don’t belong to any group
§Type Parameters
G: Group identifier type for organizing related checkable items- Used by both
CheckBoxandRadiovariants - Must implement
Clone(for storing in the manager) - Typically use
&'static stror enum variants for type safety
- Used by both
§Example
use std::rc::Rc;
use tray_controls::CheckMenuKind;
use tray_icon::menu::{CheckMenuItem, MenuId};
// Create a checkbox belonging to "display_group" group
let checkbox = CheckMenuItem::with_id("show_toolbar", "Show Toolbar", true, false, None);
let check_kind = CheckMenuKind::CheckBox(Rc::new(checkbox), "display_group");
// Create a radio button in "theme_group" group with default selection
let radio = CheckMenuItem::with_id("light_theme", "Light Theme", true, true, None);
let radio_kind = CheckMenuKind::Radio(
Rc::new(radio),
Some(Rc::new(MenuId::new("light_theme"))),
"theme_group"
);
// Create a standalone checkbox
let separate = CheckMenuItem::new("Auto-save", true, true, None);
let separate_kind: CheckMenuKind<&str> = CheckMenuKind::Separate(Rc::new(separate));Variants§
CheckBox(Rc<CheckMenuItem>, G)
A standard checkbox with group association
- First parameter: The checkbox menu item
- Second parameter: Group identifier for logical grouping
Radio(Rc<CheckMenuItem>, Option<Rc<MenuId>>, G)
A radio button with optional default selection and group association
- First parameter: The radio button menu item
- Second parameter: Optional default menu ID to select when no radio is checked.
If
Some, this menu will be selected when all radios in the group are unchecked. IfNone, no menu will be selected when all radios are unchecked. - Third parameter: Group identifier for exclusive selection
Separate(Rc<CheckMenuItem>)
A standalone checkbox with no group association
- Parameter: The standalone checkbox menu item
Trait Implementations§
Source§impl<G: Clone> Clone for CheckMenuKind<G>
impl<G: Clone> Clone for CheckMenuKind<G>
Source§fn clone(&self) -> CheckMenuKind<G>
fn clone(&self) -> CheckMenuKind<G>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<G> Freeze for CheckMenuKind<G>where
G: Freeze,
impl<G> !RefUnwindSafe for CheckMenuKind<G>
impl<G> !Send for CheckMenuKind<G>
impl<G> !Sync for CheckMenuKind<G>
impl<G> Unpin for CheckMenuKind<G>where
G: Unpin,
impl<G> !UnwindSafe for CheckMenuKind<G>
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