Skip to content

WindowHandle

Namespace: Hex1b

Assembly: Hex1b.dll

A factory/descriptor for creating windows using the fluent builder pattern. WindowHandle captures the configuration and content callback, which are invoked during reconciliation to build the actual widget tree.

csharp
public sealed class WindowHandle

Inheritance

ObjectWindowHandle

Methods

AllowOutOfBounds()

Allows this window to be moved outside the panel bounds.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle AllowOutOfBounds()

Cancel()

Closes this window without a result, signaling cancellation. The OnResult callback will receive IsCancelled = true.

csharp
public void Cancel()

CloseWithResult<T>(T)

Closes this window with a typed result value. Used for modal dialogs that return a result to the caller.

Parameters:

  • result (<T>): The result value to return.
csharp
public void CloseWithResult<T>(T result)

EscapeBehavior(WindowEscapeBehavior)

Sets the escape key behavior for this window.

Parameters:

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle EscapeBehavior(WindowEscapeBehavior behavior)

LeftTitleActions(Func<TitleActionBuilder, IEnumerable<TitleAction>>)

Configures the actions displayed on the left side of the title bar.

Parameters:

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle LeftTitleActions(Func<TitleActionBuilder, IEnumerable<TitleAction>> builder)

Makes this a modal window that blocks interaction with other windows.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle Modal()

NoTitleBar()

Hides the title bar, creating a frameless window.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle NoTitleBar()

OnActivated(Action)

Registers a callback to be invoked when the window becomes active (brought to front).

Parameters:

  • onActivated (Action): The callback to invoke on activation.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle OnActivated(Action onActivated)

OnClose(Action)

Registers a callback to be invoked when the window is closed.

Parameters:

  • onClose (Action): The callback to invoke on close.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle OnClose(Action onClose)

OnDeactivated(Action)

Registers a callback to be invoked when the window loses active status.

Parameters:

  • onDeactivated (Action): The callback to invoke on deactivation.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle OnDeactivated(Action onDeactivated)

OnResult<T>(Action<WindowResultContext<T>>)

Registers a callback to be invoked when the window closes with a typed result.

Parameters:

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle OnResult<T>(Action<WindowResultContext<T>> callback)

Open(WindowManager)

Opens this window using the specified window manager. Convenience method for fluent chaining.

Parameters:

  • manager (WindowManager): The window manager to open the window with.

Returns: WindowEntry

The opened window entry.

csharp
public WindowEntry Open(WindowManager manager)

Position(int, int)

Sets the initial position of the window.

Parameters:

  • x (Int32): The X coordinate.
  • y (Int32): The Y coordinate.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle Position(int x, int y)

Position(WindowPositionSpec)

Sets the positioning strategy for initial placement.

Parameters:

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle Position(WindowPositionSpec position)

Resizable(int, int, int?, int?)

Makes this window resizable by dragging edges and corners.

Parameters:

  • minWidth (Int32): Minimum width constraint.
  • minHeight (Int32): Minimum height constraint.
  • maxWidth (Nullable<Int32>): Maximum width constraint (null = unbounded).
  • maxHeight (Nullable<Int32>): Maximum height constraint (null = unbounded).

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle Resizable(int minWidth = 10, int minHeight = 5, int? maxWidth = null, int? maxHeight = null)

RightTitleActions(Func<TitleActionBuilder, IEnumerable<TitleAction>>)

Configures the actions displayed on the right side of the title bar. If not called, defaults to a single close button.

Parameters:

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle RightTitleActions(Func<TitleActionBuilder, IEnumerable<TitleAction>> builder)

Size(int, int)

Sets the initial size of the window.

Parameters:

  • width (Int32): The window width.
  • height (Int32): The window height.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle Size(int width, int height)

Title(string)

Sets the window title displayed in the title bar.

Parameters:

  • title (String): The window title.

Returns: WindowHandle

This handle for fluent chaining.

csharp
public WindowHandle Title(string title)

Remarks

WindowHandle provides a fluent API for defining windows that integrates with the widget builder experience. The handle itself serves as the identity for the window - no string ID is required.

Example usage:

csharp
var window = e.Windows.Window(w => w.VStack(v => [
    v.Text("Settings"),
    v.Button("Close").OnClick(ev => ev.Windows.Close(w.Window))
]))
.Title("Settings")
.Size(40, 20)
.RightTitleActions(t => [t.Close()]);

e.Windows.Open(window);

Released under the MIT License.