Class Window
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
contextIServiceProvider
Fields
OpenWindows
Gets a read-only list of all currently open Xui windows.
public static IReadOnlyList<Window> OpenWindows
Field Value
Properties
Actual
Gets the underlying platform-specific window instance.
public IWindow Actual { get; }
Property Value
Content
public View Content { init; }
Property Value
Context
public IServiceProvider Context { get; }
Property Value
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
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
Remarks
Used by the layout system to determine the full available size.
DisposeQueue
public List<IDisposable> DisposeQueue { get; }
Property Value
RequireKeyboard
Requests that the soft keyboard be shown or hidden (on supported platforms).
public bool RequireKeyboard { get; set; }
Property Value
RootView
public RootView RootView { get; }
Property Value
Runtime
public IRuntime Runtime { get; }
Property Value
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
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
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
Title
Gets or sets the window title (where supported by the platform).
public string Title { get; set; }
Property Value
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
trueif the window may close; otherwise,false.
CreateActualWindow()
Creates the platform-specific window for this abstract window.
protected virtual IWindow CreateActualWindow()
Returns
DeleteBackwards(ref DeleteBackwardsEventRef)
Requests deletion of content preceding the caret or selection.
public virtual void DeleteBackwards(ref DeleteBackwardsEventRef eventRef)
Parameters
eventRefDeleteBackwardsEventRefThe 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
GetService(Type)
Gets the service object of the specified type.
public virtual object? GetService(Type serviceType)
Parameters
serviceTypeTypeAn 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
eventRefInsertTextEventRefThe 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
OnChar(ref KeyEventRef)
Invoked when a character is input (after keyboard translation).
public virtual void OnChar(ref KeyEventRef e)
Parameters
eKeyEventRefThe keyboard event data with the translated character.
OnKeyDown(ref KeyEventRef)
Invoked when a key is pressed.
public virtual void OnKeyDown(ref KeyEventRef e)
Parameters
eKeyEventRefThe keyboard event data.
OnMouseDown(ref MouseDownEventRef)
Invoked when a mouse button is pressed within the window.
public virtual void OnMouseDown(ref MouseDownEventRef e)
Parameters
OnMouseMove(ref MouseMoveEventRef)
Invoked when the mouse is moved within the window.
public virtual void OnMouseMove(ref MouseMoveEventRef e)
Parameters
OnMouseUp(ref MouseUpEventRef)
Invoked when a mouse button is released within the window.
public virtual void OnMouseUp(ref MouseUpEventRef e)
Parameters
OnScrollWheel(ref ScrollWheelEventRef)
Invoked when the scroll wheel is used within the window.
public virtual void OnScrollWheel(ref ScrollWheelEventRef e)
Parameters
OnTouch(ref TouchEventRef)
Invoked when touch input occurs within the window.
public virtual void OnTouch(ref TouchEventRef e)
Parameters
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
renderEventRefRenderEventRef
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
evRefWindowHitTestEventRefThe hit test event containing pointer position and window bounds.