Skip to main content

Window Element

Window is a module that provides functionality for creating and managing GUI windows.
It handles window creation, event management, and provides signals for various window interactions.

Window Element
Element
LuaRT Element

Constructor

Window.new()
Function

Window.new(WindowProperties)

  • Creates a new window instance with the specified properties.

Parameters:

  • title

    string

    • Title of the Window.
  • style

    Enum.WindowStyle

    • Style of the Window.
  • width

    number

    • Width of the Window.
  • height

    number

    • Height of the Window.
  • allowdrop

    boolean?

    • Whether the Window is a drag and drop target.
  • cursor

    Enum.CursorStyle?

    • Mouse cursor image when hovering over the Window.
  • x

    number?

    • Horizontal position of the Window.
  • y

    number?

    • Vertical position of the Window.
  • enabled

    boolean?

    • Whether the Window responds to events.
  • visible

    boolean?

    • Whether the Window appears onscreen.
  • transparency

    number?

    • Window's transparency intensity.
  • childs

    table?

    • READONLY: List of child widgets of the Window.
  • parent

    Window?

    • READONLY: Parent Window. Probably "root",check Weo Core for parent handling.
  • monitor

    table?

    • READONLY: Monitor in which the Window is located.
  • topmost

    boolean?

    • Whether the Window stays above others.
  • fullscreen

    boolean?

    • Whether the Window is fullscreen.
  • font

    string?

    • Font family.
  • fontstyle

    string?

    • Font style.
  • fontsize

    number?

    • Font size.
  • bgcolor

    number?
    LinearGradient?
    RadialGradient?

    • Background color of the Window,it's pointless after creating a RenderSurface element.
  • traytooltip

    string?

    • Tooltip for the tray icon.
  • icon

    string?

    • Icon path for the tray icon.

    Please use (Window):loadicon(path,index) to load the icon instead of this property.

Signals

(Window).Shown
Signal

  • Fires when the window is shown.

(Window).Hidden
Signal

  • Fires when the window is hidden.

(Window).Closed
Signal

  • Fires when the window is closed.

(Window).Moved
Signal

  • Fires when the window is moved.

Parameters:

  • position
    Vector2
    — new window position

(Window).Resized
Signal

  • Fires when the window is resized.

Parameters:

  • width
    number
    — new window width
  • height
    number
    — new window height

(Window).MouseButton1Click
Signal

  • Fires when left mouse button is clicked on the window.

Parameters:

  • position
    Vector2
    — click position relative to window

(Window).MouseButton2Click
Signal

  • Fires when right mouse button is clicked on the window.

Parameters:

  • position
    Vector2
    — click position relative to window

(Window).MouseHover
Signal

  • Fires when mouse hovers over the window.

Parameters:

  • position
    Vector2
    — hover position relative to window
  • buttons
    table
    — mouse buttons state
    • Table containing mouse button states:
      • left — Left mouse button state.
      • middle — Middle mouse button state.
      • right — Right mouse button state.
      • control — Control key state.
      • shift — Shift key state.

(Window).KeyDown
Signal

  • Fires when a keyboard key is pressed while window has focus.

Parameters:

  • key
    string
    — the pressed key

(Window).Created
Signal

  • Fires when the window is successfully created.

(Window).MouseButtonDown
Signal

  • Fires when left mouse button is pressed down.

Parameters:

  • position
    Vector2
    — mouse position relative to window
  • buttons
    table
    — mouse buttons state
    • Table containing mouse button states:
      • left — Left mouse button state.
      • middle — Middle mouse button state.
      • right — Right mouse button state.
      • control — Control key state.
      • shift — Shift key state.

(Window).MouseButtonUp
Signal

  • Fires when left mouse button is released.

Parameters:

  • position
    Vector2
    — mouse position relative to window
  • buttons
    table
    — mouse buttons state
    • Table containing mouse button states:
      • left — Left mouse button state.
      • middle — Middle mouse button state.
      • right — Right mouse button state.
      • control — Control key state.
      • shift — Shift key state.

(Window).Minimized
Signal

  • Fires when the window is minimized.

(Window).Maximized
Signal

  • Fires when the window is maximized.

(Window).Restored
Signal

  • Fires when the window is restored from minimized/maximized state.

(Window).ContentDropped
Signal

  • Fires when content is dropped onto the window (drag-and-drop).

Parameters:

  • kind
    string
    — type of dropped content "text" | "files" | "unknown"
  • content
    any
    — the dropped content string | {[index] = File} | nil

(Window).ThemeChanged
Signal

  • Fires when the system theme changes.

Parameters:

  • theme
    string
    "dark" or "light"

System Tray Signals

  • Check (Window):loadtrayicon(path, index) and (Window).traytooltip.

(Window).TrayClicked
Signal

  • Fires when the system tray icon is clicked.

(Window).TrayDoubleClicked
Signal

  • Fires when the system tray icon is double-clicked.

(Window).TrayMouseHover
Signal

  • Fires when mouse hovers over the system tray icon.

(Window).TrayMouse2Click
Signal

  • Fires when right mouse button is clicked on the system tray icon.

Methods

  • These methods are provided by LuaRT itself.

(Window):center()

Method

  • Centers the window on its parent.

(Window):show()
Method

Windows that created by Weo starts shown by default.

  • Makes the window visible.

(Window):hide()
Method

  • Hides the window.

(Window):showmodal()
Method

(Window):showmodal(child)

  • Shows another window as modal.

Parameters:

  • child — the window to show as modal

(Window):minimize()
Method

  • Minimizes the window to the taskbar.

(Window):maximize()
Method

  • Maximizes the window.

(Window):restore()
Method

  • Restores previous size and position.

(Window):startmoving()
Method

  • Begins dragging the window.

(Window):popup()
Method

(Window):popup(menu)

  • Shows a popup menu (LuaRT Element) at the mouse position.

Parameters:

  • menu — the menu to display

(Window):shortcut()
Method

(Window):shortcut(key, callback, ctrl, shift, alt)

  • Registers a keyboard shortcut.

Please use Input Service to register keyboard shortcuts, not this method.

Parameters:

  • key — the key to register
  • callback — function to call when shortcut is triggered
  • ctrl — whether Ctrl key is required (boolean)
  • shift — whether Shift key is required (boolean)
  • alt — whether Alt key is required (boolean)

(Window):loadicon()
Method

(Window):loadicon(path, index)

  • Loads an icon for the window.

Parameters:

  • path — path to the icon file
  • index — index of the icon in the file

Returns:

  • boolean
    boolean

(Window):notify()
Method

(Window):notify(title, message, iconstyle)

  • Sends a Windows notification.

Please use Notify to send notifications, not this method.

Parameters:

  • title — notification title
  • message — notification message
  • iconstyle — style of the notification icon

Returns:

  • boolean
    boolean

(Window):loadtrayicon()
Method

(Window):loadtrayicon(path, index)

  • Loads a tray icon.

Parameters:

  • path — path to the icon file
  • index — index of the icon in the file

Returns:

  • boolean
    boolean

(Window):status()
Method

(Window):status(...)

  • Displays messages in the status bar.

Parameters:

  • ... — variable arguments for status messages

(Window):tofront()
Method

  • Brings the window to front.

(Window):toback()
Method

  • Sends the window to back.

Example

local Weo = require("Weo.core.Weo")

local window = Window.new {
style = Enum.WindowStyle.Dialog,
title = "Weo",
width = 640,
height = 480,
allowdrop = true,
}

window.MouseButton1Click:Connect(function(Position)
window:status("X: " .. Position.x .. " Y: " .. Position.y, "LMB")
end)

window.MouseButton2Click:Connect(function(Position)
window:status("X: " .. Position.x .. " Y: " .. Position.y, "RMB")
end)

Input.InputBegan:Connect(function(input)
if input.InputType == Enum.InputType.Keyboard then
if input.InputCode == Enum.VirtualKeyCodes.Key.ESCAPE then
UpdateService:Kill()
end
end
end)

UpdateService.Heartbeat:Connect(function(DeltaTime)
window:status("FPS: " .. math.floor(1 / DeltaTime))
end)

UpdateService:Run(100)

Notes

  • See LuaRT Window Documentation for details.
  • The parent property is automatically set to "root" if the parent equals the window itself. See Weo Core for parent handling.
  • RenderSurface stops updating :onPaint() after the window hidden and shown again. It's a known bug in LuaRT 2.0.1 x64 and not an issue of Weo.
    • You can force (RenderSurface):Refresh(force : boolean) to update RenderSurface with UpdateService.Heartbeat, but performance is not guaranteed since this is a workaround for the issue.