SplitButtonWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A split button with a primary action and a dropdown for secondary actions. The main button area triggers the primary action, while the dropdown arrow opens a menu.
public sealed record SplitButtonWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<SplitButtonWidget>Inheritance
Object → Hex1bWidget → SplitButtonWidget
Implements
Constructors
SplitButtonWidget()
Creates a split button. Use to set the primary action label and handler.
public SplitButtonWidget()Properties
PrimaryLabel
The label for the primary action button.
Returns: String
public string PrimaryLabel { get; init; }Methods
OnDropdownOpened(Action)
Sets a callback invoked when the dropdown menu is opened.
Parameters:
callback(Action): The callback invoked when the dropdown opens.
Returns: SplitButtonWidget
A new widget instance with the callback configured.
public SplitButtonWidget OnDropdownOpened(Action callback)PrimaryAction(string, Action<SplitButtonClickedEventArgs>)
Sets the primary action with a label and synchronous handler.
Parameters:
label(String): The label displayed on the primary button.handler(Action<SplitButtonClickedEventArgs>): The handler invoked when the primary button is clicked.
Returns: SplitButtonWidget
A new widget instance with the primary action configured.
public SplitButtonWidget PrimaryAction(string label, Action<SplitButtonClickedEventArgs> handler)PrimaryAction(string, Func<SplitButtonClickedEventArgs, Task>)
Sets the primary action with a label and asynchronous handler.
Parameters:
label(String): The label displayed on the primary button.handler(Func<SplitButtonClickedEventArgs, Task>): The async handler invoked when the primary button is clicked.
Returns: SplitButtonWidget
A new widget instance with the primary action configured.
public SplitButtonWidget PrimaryAction(string label, Func<SplitButtonClickedEventArgs, Task> handler)SecondaryAction(string, Action<SplitButtonClickedEventArgs>)
Adds a secondary action to the dropdown menu.
Parameters:
label(String): The label for the action.handler(Action<SplitButtonClickedEventArgs>): The handler invoked when this action is selected.
Returns: SplitButtonWidget
A new widget instance with the action added.
public SplitButtonWidget SecondaryAction(string label, Action<SplitButtonClickedEventArgs> handler)SecondaryAction(string, Func<SplitButtonClickedEventArgs, Task>)
Adds an asynchronous secondary action to the dropdown menu.
Parameters:
label(String): The label for the action.handler(Func<SplitButtonClickedEventArgs, Task>): The async handler invoked when this action is selected.
Returns: SplitButtonWidget
A new widget instance with the action added.
public SplitButtonWidget SecondaryAction(string label, Func<SplitButtonClickedEventArgs, Task> handler)Fields
ActivateActionId
Action ID for activating the primary action.
Returns: ActionId
public static readonly ActionId ActivateActionIdOpenMenuActionId
Action ID for opening the dropdown menu.
Returns: ActionId
public static readonly ActionId OpenMenuActionIdRemarks
The split button renders as: [ Primary ▼ ] where "Primary" is the label from the primary action.
Interaction: Clicking the main label area (or pressing Enter when focused) triggers the primary action.Clicking the dropdown arrow (▼) opens a popup menu with secondary actions.Pressing Down arrow when focused also opens the dropdown menu.
Split buttons are useful when you have a default action that users commonly want, but also need to expose related alternative actions without cluttering the UI.
Examples
A save button with alternative save options:
ctx.SplitButton()
.PrimaryAction("Save", e => SaveFile())
.SecondaryAction("Save As...", e => SaveAs())
.SecondaryAction("Save All", e => SaveAll())
.SecondaryAction("Save Copy", e => SaveCopy())