natiny.window.set_state

Lua
natiny.window.set_state(win, state)

Requests one of four exclusive window states: normal, minimized, maximized or fullscreen.

Parameters

Name Type Description
win number Window handle from natiny.window.create
state number One of the constants below

States

Constant Desktop Web Android
natiny.window.STATE_NORMAL Restores the window from minimized, maximized or fullscreen Leaves fullscreen Shows the status bar
natiny.window.STATE_MINIMIZED Minimizes the window No effect No effect
natiny.window.STATE_MAXIMIZED Maximizes the window No effect No effect
natiny.window.STATE_FULLSCREEN Borderless fullscreen on the monitor the window is mostly on Fullscreen API Hides the status bar

The requested state replaces the current state. For example, requesting natiny.window.STATE_MAXIMIZED for a fullscreen window leaves fullscreen before maximizing the window.

Example

Lua
if natiny.input.get_key_pressed(natiny.input.KEY_F11) then
    if natiny.window.get_state(win) == natiny.window.STATE_FULLSCREEN then
        natiny.window.set_state(win, natiny.window.STATE_NORMAL)
    else
        natiny.window.set_state(win, natiny.window.STATE_FULLSCREEN)
    end
end

Notes

  • Web and Android builds support only natiny.window.STATE_NORMAL and natiny.window.STATE_FULLSCREEN. Other states have no effect.
  • On Android, fullscreen hides the status bar but does not hide the navigation bar.