Window
Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.
Up and coming
Open a real desktop window from code: give it a title and a menu bar, ask before it closes, and have it come back where you left it.
A Window shows while it is in your program's tree, from the start of the run or from when code parents one in; with Parent nil it hides and stays alive. Sizes are in logical pixels, and SizeChanged is the one resize hook, where a scripted layout starts. A confirm box and the Windows file and folder pickers are ready-made on every Window. Once your code has returned and nothing else is running, closing the last window ends the run.
Made with Instance.new("Window") or Clone().
local function example(x : Window)
local window = Instance.new("Window")
window.Title = "Manager"
window.SizeChanged:Connect(function(size : Vector2)
print(size.X)
end)
endProperties
| Name | Type | Default | Description |
|---|---|---|---|
| Title | string | ||
| Icon | Icon? | The picture in the title bar and on the taskbar button. | |
| Size | Vector2 | The inside of the window in logical pixels; resizing the window by hand changes it too. | |
| MinSize | Vector2 | The system stops a resize at this size, so your scripted layout has a floor. | |
| Position | Vector2? | Where the window sits on the desktop, in logical pixels; nil centres it on the main monitor. | |
| State | "Normal" | "Maximized" | "Minimized" | ||
| Resizable | boolean | ||
| AlwaysOnTop | boolean | ||
| BackgroundColor | Color3 | Near-white by default: windows are light mode. | |
| SaveKey | string? | Remembers the size, position and state for each user under this name and restores them on the next run. | |
| DpiScale | number | read-only | 1.5 at 150% scaling; everything is in logical pixels, and text is redrawn sharp when the window moves to another monitor. |
| Focused | boolean | read-only | |
| FocusedObject | UIObject? | read-only | The TextBox or Button that has the keyboard; Tab and Shift+Tab move it through them in tree order. |
| MousePosition | Vector2 | read-only | The pointer's position, in window coordinates. |
| MenuBar | Menu? | A menu bar along the top of the window, such as File and View. |
Methods
| Name | Arguments | Returns | Description |
|---|---|---|---|
| Focus | () | () | Brings the window to the front; Windows may flash its taskbar button instead. |
| Flash | () | () | Flashes the window's taskbar button until you look at it. |
| Notify | (text: string, color: Color3?, seconds: number?) | () | Shows a toast that slides in at the bottom and fades out. |
| Close | () | () | Closes the window, as Destroy does; setting Parent to nil only hides it, and putting it back shows it again. |
| IsKeyDown | (key: KeyCode) | boolean | |
| SetClipboard | (text: string) | () | |
| GetClipboardAsync yields | () | string | |
| ConfirmAsync yields | (title: string, text: string, buttons: { string }) | string? | Shows a confirm box drawn in the window's own look and waits for a button; Enter picks the first, Escape gives nil. |
| PickFolderAsync yields | (title: string?, start: string?) | string? | Opens the Windows folder picker and waits for the pick. |
| PickFilesAsync yields | (filters: { [string]: string }?, multiple: boolean?) | { string } | Opens the Windows file picker and waits for the pick; filters look like {Images = "png;jpg"}. |
| PickSaveFileAsync yields | (name: string?, filters: { [string]: string }?) | string? | Opens the Windows picker for a file to save and waits for the pick. |
Events
| Name | Passes | Description |
|---|---|---|
| SizeChanged | (Vector2) | Fires with the new size; the one resize hook, where a scripted layout starts, with no size listeners on each element. |
| CloseRequested | () | While connected, the window stays open until your code calls Close, so it can ask first; with nothing connected, it closes. |
| Closed | () | |
| FocusChanged | (boolean) | |
| DpiChanged | (number) | |
| InputBegan | (InputObject) | Fires for keys and buttons anywhere in the window, after the focused control has had them. |
| InputEnded | (InputObject) | |
| FilesDropped | ({ string }, Vector2) | Fires when files dragged in from File Explorer land on no DropTarget, passing their paths and where they landed. |
From ScreenItem 2
From ShotInstance 33
ClassNameNameParentAncestryChangedAttributeChangedChangedChildAddedChildRemovedDestroyingAddTagClearAllChildrenCloneDestroyFindFirstAncestorFindFirstAncestorOfClassFindFirstAncestorWhichIsAFindFirstChildFindFirstChildOfClassFindFirstChildWhichIsAGetAttributeGetAttributeChangedSignalGetAttributesGetChildrenGetDescendantsGetFullNameGetPropertyChangedSignalGetTagsHasTagIsAIsAncestorOfIsDescendantOfRemoveTagSetAttribute
Subclasses
