Skip to main content

togglebutton

Macro togglebutton 

Source
togglebutton!() { /* proc-macro */ }
Expand description

Creates a new toggle button control that can be toggled on/off. The format is togglebutton!("attributes") where the attributes are pairs of key-value, separated by comma.

§Parameters

  • caption or name or text (required, first positional parameter) - The text displayed on the button
  • tooltip or description or desc (optional, second positional parameter) - Tooltip text shown on hover
  • type - Button type (optional). Can be:
    • Normal (default) - Standard toggle button
    • Underlined - Button with underlined text
  • select or selected or state - Initial selected state (optional, defaults to false)
  • group or single_selection - Whether the button is part of a single-selection group (optional, defaults to false)
  • Position and size:
    • x, y - Position coordinates
    • width/w, height/h - Control dimensions
  • Layout:
    • align/a - Alignment: Left, Right, Top, Bottom, Center, etc.
    • dock/d - Docking: Left, Right, Top, Bottom, Center, etc.
  • Margins: left/l, right/r, top/t, bottom/b
  • State: enabled, visible

§Examples

use appcui::prelude::*;
 
// Basic toggle button
let btn = togglebutton!("'Enable Feature', x=1, y=1, width=20");
 
// Toggle button with tooltip and initial state
let btn = togglebutton!(
    "caption: 'Auto-save',
    tooltip: 'Enable automatic saving of changes',
    selected: true,
    x=2, y=2, width=25"
);
 
// Underlined toggle button in a single-selection group
let btn = togglebutton!(
    "'Option A',
    type: Underlined,
    group: true,
    x=3, y=3, width=15"
);