Window - stingray.Window object reference - Stingray Lua API Reference

stingray.Window object reference

Description

Represents an application window on Win32 and MacOS X.

On other platforms, there may not be a window.

Window functions may be called in two ways:

  • Not passing any Window object to the function. In this case, the function affects the main application window. For example:

    -- Sets the title of the main window
    Window.set_title("main window")
    
  • Or, by passing an existing Window object to the function. In this case, the function affects the window that you pass. For example:

    -- Creates a new window and sets its title
    win = Window.open()
    Window.set_title(win, "new window")
    

Functions

Parameters

window :

stingray.Window

The window to test. Optional; if not specified, uses the main application window.

Returns

boolean

true if the window confines the mouse pointer within its borders, or false otherwise.

Parameters

window :

stingray.Window

The window to close. Optional; if not specified, uses the main application window.

Returns
This function does not return any values.

Available only for Windows platforms.

Parameters
This function does not accept any parameters.
Returns

number

Windows DPI scale. 1.0 on non-windows platforms.

Available only for Windows platforms.

Parameters

window :

stingray.Window

The window to test. Optional; if not specified, uses the main application window.

Returns

boolean

true if the window has keyboard focus, or false otherwise.

Parameters

window :

stingray.Window

The window to test. Optional; if not specified, uses the main application window.

Returns

boolean

true if the user has pressed the "close" icon for the specified window.

Available only for Windows platforms.

Parameters

window :

stingray.Window

The window to test. Optional; if not specified, uses the main application window.

Returns

boolean

true if the window has a resizable border, or false otherwise.

Parameters

window :

stingray.Window

The window to maximize. Optional; if not specified, uses the main application window.

Returns
This function does not return any values.

Available only for Windows platforms.

Parameters

window :

stingray.Window

The window to minimize. Optional; if not specified, uses the main application window.

Returns
This function does not return any values.

Available only for Windows platforms.

Parameters

window :

stingray.Window

The window to test. Optional; if not specified, uses the main application window.

Returns

boolean

true if the window has mouse focus, or false otherwise.

When the window has mouse focus, it will hide the mouse pointer from the user and prevent the pointer from leaving the window.

Parameters

config :

window_config?

Optional. A window_config table that provides settings for the new window.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.

Available only for Windows platforms.

Returns

number

The x coordinate of the window.

number

The y coordinate of the window.

number

The width of the window.

number

The height of the window.

Parameters

window :

stingray.Window

The window to restore from being maximized or minimized. Optional; if not specified, uses the main application window.

Returns
This function does not return any values.

Available only for Windows platforms.

Parameters

window :

stingray.Window

The window whose cursor setting will be set. Optional; if not specified, uses the main application window.

doClip :

boolean

Pass true to make the window confine the mouse pointer within its borders, or false otherwise.

Returns
This function does not return any values.
Parameters

window :

stingray.Window

The window whose mouse cursor will be set. Optional; if not specified, uses the main application window.

cursor :

string

The name of the mouse cursor resource to use for this window.

Returns
This function does not return any values.

This cursor is used when the window has focus and the window is set to show a cursor (see also show_cursor() and set_show_cursor()).

The cursor parameter should be the name of a resource file in the project data directory that has the .mouse_cursor extension. This file must contain a single texture parameter, which points to the .texture resource that you want to use for the cursor image.

For example, if you create a resource called content/camera.mouse_cursor that contains the following line:

texture = "core/editor_slave/resources/gui/thumbnail_over"

You can assign it to the window by calling:

stingray.Window.set_cursor("content/camera")
Parameters

window :

stingray.Window

The window whose focus will be set. Optional; if not specified, uses the main application window.

Returns
This function does not return any values.
Parameters

window :

stingray.Window

The window to configure. Optional; if not specified, uses the main application window.

isEnabled :

boolean

true if the IME should be enabled for this window, or false otherwise.

Returns
This function does not return any values.

The IME is disabled by default.

Parameters

window :

stingray.Window

Deprecated - The window parameter will be ignored and the implementation will use the main application window.

key :

integer

The keystroke or key combination to enable or disable.

isEnabled :

boolean

true if the specified key should be enabled for this window, or false otherwise.

Returns
This function does not return any values.

Accepts any of the keystroke constants defined in the Window object: KEYSTROKE_WINDOWS, KEYSTROKE_ALT_TAB, KEYSTROKE_ALT_ENTER, or KEYSTROKE_ALT_F4.

Available only for Windows platforms.

Parameters

window :

stingray.Window

The window whose focus will be set. Optional; if not specified, uses the main application window.

focus :

boolean

Pass true to give the window mouse focus, or false to remove mouse focus.

Returns
This function does not return any values.
Parameters

x :

number

The x coordinate of the window.

y :

number

The y coordinate of the window.

width :

number

The width of the window.

height :

number

The height of the window.

Returns
This function does not return any values.
Parameters

window :

stingray.Window

The window whose border will be set. Optional; if not specified, uses the main application window.

resizeable :

boolean

Pass true if the window should have a resizable border, or false otherwise.

Returns
This function does not return any values.
Parameters

window :

stingray.Window

The window whose resolution will be set. Optional; if not specified, uses the main application window.

width :

integer

The horizontal width of the window, in pixels.

height :

integer

The vertical height of the window, in pixels.

Returns

boolean

true if the resolution could be set correctly, or false otherwise.

Parameters

window :

stingray.Window

The window whose cursor setting will be set. Optional; if not specified, uses the main application window.

do_show :

boolean

Pass true to make the window show the mouse pointer when it has focus, or false otherwise.

restore_cursor_pos :

boolean

When you show the cursor after it has been hidden, pass true to this parameter in order to make the cursor appear at its last visible position. Pass false to make the cursor appear at the position tracked by the operating system. Optional; if not specified, defaults to true.

Returns
This function does not return any values.
Parameters

window :

stingray.Window

The window whose title will be set. Optional; if not specified, uses the main application window.

title :

string

The new title for the window.

Returns
This function does not return any values.
Parameters

window :

stingray.Window

The window to test. Optional; if not specified, uses the main application window.

Returns

boolean

true if the window is set to show the mouse cursor, or false otherwise.

Parameters

x :

number

The x coordinate of the window.

y :

number

The y coordinate of the window.

width :

number

The width of the window.

height :

number

The height of the window.

visible :

boolean

Indicates if the window will be hidden or shown

opacity :

number

Set the layered window transparency.

Returns
This function does not return any values.
Parameters

window :

stingray.Window

The window to trigger resize on. Optional; if not specified, uses the main application window.

Returns
This function does not return any values.

If the size has not been changed since last triggered it has no effect. Available only for Windows platforms.

Window key combinations

Constants used to represent keystrokes and key combinations that interact with windows.