UI / WIDGETS / Actions
SplitButton
Combine a primary action with alternatives
Run the Xu example ↗The example executes in the browser using the Xu/WASM runtime.
What to try
Use the main action and choose an alternative.
Usage notes
Use Menu in split mode. The default command and the alternatives menu are separate actions and need separate names and handling.
Create through Screen
The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.
Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.
#ui/widgets
fn configure(screen $&widgets.Screen) int {
items := [widgets.menu_item(1,"Save"),widgets.menu_item(2,"Export")]
id := screen.menu("Save",&items,widgets.MENU_SPLIT,1) or >>
screen.place(id,24.0,24.0,320.0,80.0) or >>
<< id
}
Placement, state and events
The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.
Action · Styles · UI lifecycle and styling guide
Screen.place · Screen.set_enabled · Screen.set_visible
Standalone control object API
These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.
Complete native example
Component Workshop · Back to Widgets