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
captionornameortext(required, first positional parameter) - The text displayed on the buttontooltipordescriptionordesc(optional, second positional parameter) - Tooltip text shown on hovertype- Button type (optional). Can be:- Normal (default) - Standard toggle button
- Underlined - Button with underlined text
selectorselectedorstate- Initial selected state (optional, defaults to false)grouporsingle_selection- Whether the button is part of a single-selection group (optional, defaults to false)- Position and size:
x,y- Position coordinateswidth/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"
);