pub enum CheckMenuKind<G> {
CheckBox(Rc<CheckMenuItem>, G),
Radio(Rc<CheckMenuItem>, 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>, defaultMenuId, and group identifierG - Purpose: A radio button where only one item in the same group can be selected
- Default ID: Specifies which menu should be selected when no radio in the group is checked
- 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),
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§
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