CheckMenuKind

Enum CheckMenuKind 

Source
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 identifier G
  • Purpose: A standard checkbox that can be checked/unchecked independently
  • Grouping: Items with the same G value belong to the same logical group

§Radio

  • Contains: Rc<CheckMenuItem>, optional default MenuId, and group identifier G
  • Purpose: A radio button where only one item in the same group can be selected
  • Default ID:
    If Some, specifies which menu should be selected when all radios in the group are unchecked.
    If None, no action is taken when all radios are unchecked.
  • Grouping: All radio buttons with the same G value 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 CheckBox and Radio variants
    • Must implement Clone (for storing in the manager)
    • Typically use &'static str or enum variants for type safety

§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. If None, 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>

Source§

fn clone(&self) -> CheckMenuKind<G>

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

Auto 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> 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.