WindowAction
Namespace: Hex1b
Assembly: Hex1b.dll
Represents an action button that can be displayed in a window's title bar.
csharp
public sealed record WindowAction : IEquatable<WindowAction>Inheritance
Object → WindowAction
Implements
Constructors
WindowAction(string, Action<WindowActionContext>)
Creates a new window action with the specified icon and handler.
Parameters:
icon(String): The icon to display (emoji or single character).handler(Action<WindowActionContext>): The action handler called when clicked.
csharp
public WindowAction(string icon, Action<WindowActionContext> handler)Properties
Handler
The action handler called when this button is clicked.
Returns: Action<WindowActionContext>
csharp
public Action<WindowActionContext> Handler { get; }Icon
The icon displayed for this action.
Returns: String
csharp
public string Icon { get; }Tooltip
Optional tooltip text for this action.
Returns: String
csharp
public string? Tooltip { get; init; }Methods
Close(string)
Creates a close action that closes the window when clicked.
Parameters:
icon(String): Optional custom icon. Defaults to "×".
Returns: WindowAction
A window action that closes the window.
csharp
public static WindowAction Close(string icon = "×")Remarks
Window actions receive a that provides access to the window being acted upon. This enables reusable actions like the standard close button.
Examples
csharp
// Window with default close button
var window = e.Windows.Window(w => w.Text("Content"))
.Title("My Window");
e.Windows.Open(window);
// Custom title bar actions
var editor = e.Windows.Window(w => w.Text("Editor content"))
.Title("Editor")
.RightTitleActions(a => [a.Action("?", ShowHelp), a.Close()]);
e.Windows.Open(editor);