Table of Contents

Class Window

Namespace
Xui.Core.Abstract
Assembly
Xui.Core.dll

Represents an abstract cross-platform application window in Xui. Handles input, rendering, layout, and software keyboard integration.

public class Window : IWindow, IWindow.ISoftKeyboard, IServiceProvider, IDisposable
Inheritance
Window
Implements
Inherited Members
Extension Methods

Remarks

This class connects the abstract UI framework with the underlying platform window, acting as a root container for layout and visual composition. Subclasses may override specific input or rendering behaviors as needed.

Constructors

Window(IServiceProvider)

Initializes a new instance of the Window class. This creates the backing platform window.

public Window(IServiceProvider context)

Parameters

context IServiceProvider

Fields

OpenWindows

Gets a read-only list of all currently open Xui windows.

public static IReadOnlyList<Window> OpenWindows

Field Value

IReadOnlyList<Window>

Properties

Actual

Gets the underlying platform-specific window instance.

public IWindow Actual { get; }

Property Value

IWindow

Content

public View Content { init; }

Property Value

View

Context

public IServiceProvider Context { get; }

Property Value

IServiceProvider

DestroyOnClose

When true (the default), closing the window calls Dispose(). Set to false for windows that survive being closed and reopened.

public bool DestroyOnClose { get; set; }

Property Value

bool

DisplayArea

Gets or sets the total visible area of the window, including content that may be obscured by hardware cutouts, rounded corners, or system UI overlays.

public virtual Rect DisplayArea { get; set; }

Property Value

Rect

Remarks

Used by the layout system to determine the full available size.

DisposeQueue

public List<IDisposable> DisposeQueue { get; }

Property Value

List<IDisposable>

RequireKeyboard

Requests that the soft keyboard be shown or hidden (on supported platforms).

public bool RequireKeyboard { get; set; }

Property Value

bool

RootView

public RootView RootView { get; }

Property Value

RootView

Runtime

public IRuntime Runtime { get; }

Property Value

IRuntime

SafeArea

Gets or sets the "safe" area of the window, excluding obstructions like notches or status bars. Important UI elements should be placed within this area.

public virtual Rect SafeArea { get; set; }

Property Value

Rect

Remarks

Especially relevant on mobile devices and in emulator scenarios.

ScreenCornerRadius

Gets or sets the corner radius of the physical screen, in logical pixels. Used to offset UI elements (such as scrollbar indicators) away from rounded screen edges. Zero on desktop platforms where the window has sharp corners.

public virtual NFloat ScreenCornerRadius { get; set; }

Property Value

NFloat

TextMeasureContext

Gets the text measure context for this window, used for hit-testing text positions during pointer events. Null on platforms that do not provide one.

public virtual ITextMeasureContext? TextMeasureContext { get; }

Property Value

ITextMeasureContext

Title

Gets or sets the window title (where supported by the platform).

public string Title { get; set; }

Property Value

string

Methods

Closed()

Invoked when the window is closed and cleanup should occur.

public virtual void Closed()

Closing()

Invoked before the window closes. Returning false can cancel the closure.

public virtual bool Closing()

Returns

bool

true if the window may close; otherwise, false.

CreateActualWindow()

Creates the platform-specific window for this abstract window.

protected virtual IWindow CreateActualWindow()

Returns

IWindow

The platform implementation of IWindow.

DeleteBackwards(ref DeleteBackwardsEventRef)

Requests deletion of content preceding the caret or selection.

public virtual void DeleteBackwards(ref DeleteBackwardsEventRef eventRef)

Parameters

eventRef DeleteBackwardsEventRef

The input event representing a backspace action.

Dispose()

Releases all managed resources owned by this window. If the platform window is still open, it is closed first. Items in DisposeQueue are disposed in order.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true when called from Dispose(); false from a finalizer.

GetService(Type)

Gets the service object of the specified type.

public virtual object? GetService(Type serviceType)

Parameters

serviceType Type

An object that specifies the type of service object to get.

Returns

object

A service object of type serviceType.

-or-

null if there is no service object of type serviceType.

InsertText(ref InsertTextEventRef)

Requests insertion of one or more characters into the current input context.

public virtual void InsertText(ref InsertTextEventRef eventRef)

Parameters

eventRef InsertTextEventRef

The input event containing the text to insert.

Invalidate()

Requests a visual invalidation/redraw of this window.

public virtual void Invalidate()

OnAnimationFrame(ref FrameEventRef)

Invoked once per frame to propagate animation timing information.

public virtual void OnAnimationFrame(ref FrameEventRef e)

Parameters

e FrameEventRef

OnChar(ref KeyEventRef)

Invoked when a character is input (after keyboard translation).

public virtual void OnChar(ref KeyEventRef e)

Parameters

e KeyEventRef

The keyboard event data with the translated character.

OnKeyDown(ref KeyEventRef)

Invoked when a key is pressed.

public virtual void OnKeyDown(ref KeyEventRef e)

Parameters

e KeyEventRef

The keyboard event data.

OnMouseDown(ref MouseDownEventRef)

Invoked when a mouse button is pressed within the window.

public virtual void OnMouseDown(ref MouseDownEventRef e)

Parameters

e MouseDownEventRef

OnMouseMove(ref MouseMoveEventRef)

Invoked when the mouse is moved within the window.

public virtual void OnMouseMove(ref MouseMoveEventRef e)

Parameters

e MouseMoveEventRef

OnMouseUp(ref MouseUpEventRef)

Invoked when a mouse button is released within the window.

public virtual void OnMouseUp(ref MouseUpEventRef e)

Parameters

e MouseUpEventRef

OnScrollWheel(ref ScrollWheelEventRef)

Invoked when the scroll wheel is used within the window.

public virtual void OnScrollWheel(ref ScrollWheelEventRef e)

Parameters

e ScrollWheelEventRef

OnTouch(ref TouchEventRef)

Invoked when touch input occurs within the window.

public virtual void OnTouch(ref TouchEventRef e)

Parameters

e TouchEventRef

Render(ref RenderEventRef)

Invoked during the render phase of the UI lifecycle. Responsible for triggering layout and visual updates.

public virtual void Render(ref RenderEventRef renderEventRef)

Parameters

renderEventRef RenderEventRef

Show()

Makes the window visible and adds it to the list of open windows.

public void Show()

WindowHitTest(ref WindowHitTestEventRef)

Invoked when the system requests a hit test for window interaction. Allows the app to indicate whether a region is draggable, resizable, etc.

public virtual void WindowHitTest(ref WindowHitTestEventRef evRef)

Parameters

evRef WindowHitTestEventRef

The hit test event containing pointer position and window bounds.