Window¶
The Window class enables creating, configuring, and managing windows,
Synopsis¶
Constructor¶
Static Methods¶
Instance Methods¶
window.activate()window.always_on_top()window.decorated()window.destroy()window.focus()window.focused()window.fullscreen()window.id()window.modal()window.parent()window.position()window.resizable()window.set_always_on_top([enabled])window.set_decorated([decorated])window.set_fullscreen([fullscreen])window.set_icon(path)window.set_modal([modal])window.set_parent(parent)window.set_position(x, y)window.set_resizable([resizable])window.set_size(width, height)window.set_title(title)window.set_visible([visible])window.size()window.title()window.to_canvas(x, y)window.transparent()window.valid()window.visible()
Constructor¶
Window([options])¶
Creates a new desktop window with the specified configuration configuration table.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
options |
table |
No | A table containing initialization properties. |
Window Options Table¶
| Field | Type | Default | Description |
|---|---|---|---|
title |
string |
"Nutshell" |
The title of the window. |
x |
int |
null |
The initial X position of the window. If omitted, the OS determines the position. |
y |
int |
null |
The initial Y position of the window. If omitted, the OS determines the position. |
width |
int |
640 |
The width of the client area in pixels. |
height |
int |
480 |
The height of the client area in pixels. |
hidden |
bool |
false |
If true, the window is created hidden. |
resizable |
bool |
true |
If true, the window can be manually resized. |
always_on_top |
bool |
false |
If true, the window stays above other non-pinned windows. |
utility |
bool |
false |
If true, creates a utility/panel window. |
transparent |
bool |
false |
If true, enables alpha blending transparency for the window background. |
tooltip |
bool |
false |
If true, styles the window as an OS tooltip popup. |
popup_menu |
bool |
false |
If true, styles the window as a popup/context menu. |
modal |
bool |
false |
If true, configures the window to be modal to its parent window. |
parent |
Window | int |
null |
The parent window instance or integer window ID. |
decorated |
bool |
true |
If false, creates a borderless window without standard frame styling or title bar. |
vsync |
bool | int |
true |
Vertical synchronization configuration (true/1 for on, false/0 for off). |
fullscreen |
bool |
false |
If true, initializes the window in fullscreen mode. |
Static Methods¶
Window.active()¶
Returns the active window for the current virtual machine.
- Returns:
Windowornull: The activeWindowinstance, ornullif no active window exists.
Window.focused_id()¶
Returns the currently focused window for the current virtual machine.
- Returns:
int: The focused window identifier, or0if no window has focus.
Window.focused_vm_id()¶
Returns the identifier of the virtual machine that owns the currently-focused window.
- Returns:
stringornull: The virtual machine string identifier, ornullif there is no focused window.
Instance Methods¶
window.activate()¶
Makes this window the active rendering target for the calling virtual machine.
window.always_on_top()¶
Checks whether the window is currently set to always stay on top of other standard windows.
- Returns:
bool:trueif always on top,falseotherwise.
window.decorated()¶
Checks whether the window currently has standard borders and title decorations.
- Returns:
bool:trueif decorated,falseif borderless.
window.destroy()¶
Closes the window immediately and releases its underlying system resources.
window.focus()¶
Requests to grant input and interaction focus to this window.
window.focused()¶
Checks whether this window currently has input focus.
- Returns:
bool:trueif the window is focused,falseotherwise.
window.fullscreen()¶
Checks whether this window is currently displaying in fullscreen mode.
- Returns:
bool:trueif fullscreen,falseotherwise.
window.id()¶
Returns this window identifier.
- Returns:
int: The numerical window ID.
window.modal()¶
Checks whether this window is modal relative to its parent window.
- Returns:
bool:trueif modal,falseotherwise.
window.parent()¶
Gets the parent window of this window.
- Returns:
Windowornull: The parentWindowinstance, ornullif it has no parent.
window.position()¶
Gets the current screen position coordinates of the window's outer top-left corner.
- Returns:
table
Position Table¶
| Field | Type | Description |
|---|---|---|
x |
int |
The X screen coordinate. |
y |
int |
The Y screen coordinate. |
window.resizable()¶
Checks whether the window is resizable by the user.
- Returns:
bool:trueif resizable,falseotherwise.
window.set_always_on_top([enabled])¶
Sets whether this window should stay on top of other windows.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
enabled |
bool |
No | true to pin on top, false to disable. Default: true. |
window.set_decorated([decorated])¶
Enables or disables the standard operating system window frame decorations and title bars.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
decorated |
bool |
No | true to show borders, false for borderless. Default: true. |
window.set_fullscreen([fullscreen])¶
Toggles the window into or out of fullscreen mode.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
fullscreen |
bool |
No | true for fullscreen, false for windowed mode. Default: true. |
window.set_icon(path)¶
Sets the window's taskbar and framing icon from a specified file path.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path |
string |
Yes | The path to the image resource asset. |
window.set_modal([modal])¶
Sets whether this window behaves modally relative to its parent window structure.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
modal |
bool |
No | true to enable modal behavior, false to disable. Default: true. |
window.set_parent(parent)¶
Changes the parenting hierarchy of this window to another window, or detaches it.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
parent |
Window | int | null |
Yes | A Window instance, an integer window ID, or null to detach and clear the parent. |
window.set_position(x, y)¶
Sets the outer window coordinate location on screen in pixels.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
x |
int |
Yes | Target screen X coordinate. |
y |
int |
Yes | Target screen Y coordinate. |
window.set_resizable([resizable])¶
Enables or disables user interactive window resizing boundaries.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
resizable |
bool |
No | true to make resizable, false to lock boundaries. Default: true. |
window.set_size(width, height)¶
Sets the size of the internal drawing/client workspace area in pixels.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
width |
int |
Yes | Desired viewport width. |
height |
int |
Yes | Desired viewport height. |
window.set_title(title)¶
Updates the descriptive caption text sequence shown in the window's title bar header.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
title |
string |
Yes | The new title string content. |
window.set_visible([visible])¶
Toggles window rendering visibility states to hide or display the frame structure on screen.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
visible |
bool |
No | true to reveal the window, false to hide it. Default: true. |
window.size()¶
Gets the current dimension bounds of the inner active client area viewport in pixels.
- Returns:
table
Size Table¶
| Field | Type | Description |
|---|---|---|
width |
int |
Viewport width measurement. |
height |
int |
Viewport height measurement. |
window.title()¶
Gets the current title text sequence configured on the window frame bar.
- Returns:
string: The active title string.
window.to_canvas(x, y)¶
Converts window coordinates to canvas coordinate space.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
x |
float |
Yes | Window X coordinate. |
y |
float |
Yes | Window Y coordinate. |
- Returns:
table
Canvas Coordinates Table¶
| Field | Type | Description |
|---|---|---|
x |
int |
Canvas X coordinate. |
y |
int |
Canvas Y coordinate. |
window.transparent()¶
Checks whether this window background allows layout transparency pass-through processing.
- Returns:
bool:trueif transparent alpha handling is active,falseotherwise.
window.valid()¶
Checks whether this window instance is valid.
- Returns:
bool:trueif the window is alive and actively opened,falseif it was closed or destroyed.
window.visible()¶
Checks whether the window structure is currently visible.
- Returns:
bool:trueif visible,falseif hidden.