Skip to main content

Module split_button

Module split_button 

Source
Expand description

SplitButton — a button split into two regions sharing a single frame.

The left region is the default action: it shows the label of the currently-selected item and, on click, fires that item’s command (behaving like a regular Button). The right region is a narrow chevron zone that, on click, opens a MenuList of related actions. Picking an action from the dropdown fires it and promotes its index to become the new default for the session (IntelliJ’s “remember last used” convention).

SplitButton reuses MenuItem verbatim for the dropdown rows — the caller passes real MenuItem values via .item(...), so icons, shortcut labels, enabled flags, and separators all come for free.

let _w = SplitButton::new()
    .item(MenuItem::new(lit!("Run")).on_activate_fn(|ctx| ctx.send_intent(Intent::new("app.run"))))
    .item(MenuItem::new(lit!("Run Tests")).on_activate_fn(|ctx| ctx.send_intent(Intent::new("app.run-tests"))))
    .separator()
    .item(MenuItem::new(lit!("Debug")).on_activate_fn(|ctx| ctx.send_intent(Intent::new("app.debug"))))
    .variant(ButtonVariant::Plain);

Structs§

SplitButton
A button split into a default-action region and a chevron dropdown region.

Constants§

SPLIT_BUTTON_BORDER_WIDTH
SPLIT_BUTTON_CHEVRON_ICON_SIZE
SPLIT_BUTTON_CHEVRON_WIDTH
SPLIT_BUTTON_CORNER_RADIUS
SPLIT_BUTTON_DIVIDER_WIDTH
SPLIT_BUTTON_HEIGHT
SplitButton design tokens.
SPLIT_BUTTON_ICON_LABEL_GAP
Gap between an optional main-region leading icon and the label.
SPLIT_BUTTON_MIN_WIDTH
SPLIT_BUTTON_PADDING_HORIZONTAL
SPLIT_BUTTON_PADDING_VERTICAL