Window
Native window.
| Module | require("gui") |
| Type | Class |
Class methods
create(options)
Create a new window with options.
Parameters
Window::Optionsoptions
Return
WindowMethods
close()
Request to close the window.
hasFrame()
Return whether window has a native frame.
Return
BooleanisTransparent()
Return whether window is transparent.
Return
BooleansetHasShadow(has)
Set whether window should have shadow.
Depending on platform, this may not work.
Parameters
Booleanhas
hasShadow()
Return whether window has shadow.
Return
BooleansetContentView(view)
Set the content view of the window.
The content view will always be resized to fill window's client area.
Parameters
Viewview
getContentView()
Return the content view of the window.
Return
Viewcenter()
Move the window to the center of the screen.
setContentSize(size)
Resize window to make the content view fit size.
Parameters
SizeFsize
getContentSize()
Return the size of content view.
Return
SizeFsetBounds(bounds)
Change the position and size of the window.
Parameters
RectFbounds
getBounds()
Return the position and size of the window.
Return
RectFsetSizeConstraints(minsize, maxsize)
Set the minimum and maximum sizes of the window.
Passing an empty size means no constraint.
Parameters
getSizeConstraints()
Return minimum and maximum sizes of the window.
Return
[SizeF, SizeF]setContentSizeConstraints(minsize, maxsize)
Set the minimum and maximum content sizes of the window.
Passing an empty size means no constraint.
Parameters
getContentSizeConstraints()
Return minimum and maximum content sizes of the window.
Return
[SizeF, SizeF]activate()
Show the window and activate it.
deactivate()
Move the focus away from the window.
isActive()
Return whether window has focus.
Return
BooleansetVisible(visible)
Show/hide the window.
Parameters
Booleanvisible
isVisible()
Return whether window is visible.
Return
BooleansetAlwaysOnTop(top)
Make the window always show above other normal windows.
Parameters
Booleantop
isAlwaysOnTop()
Return whether window is always above other normal windows.
Return
BooleansetFullscreen(fullscreen)
Enter/leave fullscreen state.
Parameters
Booleanfullscreen
isFullscreen()
Return whether window is in fullscreen.
Return
Booleanmaximize()
Maximize the window.
unmaximize()
Unmaximize the window.
isMaximized()
Return whether window is maximized.
Return
Booleanminimize()
Minimize the window.
restore()
Restore the minimized window.
isMinimized()
Return whether window is minimized.
Return
BooleansetResizable(resizable)
Set whether window can be resized.
Parameters
Booleanresizable
isResizable()
Return whether window can be resized.
Return
BooleansetMaximizable(maximizable)
Set whether window can be maximize.
Parameters
Booleanmaximizable
isMaximizable()
Return whether window can be maximize.
Return
BooleansetMinimizable(minimizable)
Set whether window can be minimized.
Parameters
Booleanminimizable
isMinimizable()
Return whether window can be minimized.
Return
BooleansetMovable(movable)
Set whether window can be moved.
Parameters
Booleanmovable
isMovable()
Return whether window can be moved.
Return
BooleansetTitle(title)
Set window title.
Parameters
Stringtitle
getTitle()
Get window title.
Return
StringsetBackgroundColor(color)
Set the background color of the window.
Parameters
Colorcolor
setToolbar(toolbar) macOS
Set the window toolbar.
Parameters
Toolbartoolbar
getToolbar() macOS
Return the window toolbar.
Return
ToolbarsetTitleVisible(visible) macOS
Set whether the title is visible, when title was hidden the toolber would be moved into the area previously occupied by the title.
Parameters
Booleanvisible
isTitleVisible() macOS
Return whether title is visible.
Return
BooleansetFullSizeContentView(full) macOS
Set the NSFullSizeContentViewWindowMask style on the window.
Parameters
Booleanfull
isFullSizeContentView() macOS
Return whether the window has NSFullSizeContentViewWindowMask style.
Return
BooleansetSkipTaskbar(skip) Windows Linux
Set whether to hide the window from taskbar.
Parameters
Booleanskip
setIcon(icon) Windows Linux
Set the window icon.
Parameters
Imageicon
setMenuBar(menubar) Windows Linux
Set the window menu bar.
Parameters
MenuBarmenubar
getMenuBar() Windows Linux
Return the window menu bar.
Return
MenuBargetParentWindow()
Return the parent window.
Return
WindowaddChildWindow(child)
Make child a child window of this window.
This method will do nothing if child already has a parent window.
Parameters
Windowchild
removeChildWindow(child)
Remove this window as child's parent window.
Parameters
Windowchild
getChildWindows()
Return all the child windows of this window.
Return
ArrayEvents
onClose(self)
Emitted when the window is closed.
Parameters
Windowself
Preventable
No.onFocus(self)
Emitted when the window is focused.
Parameters
Windowself
Preventable
No.onBlur(self)
Emitted when the window lost focus.
Parameters
Windowself
Preventable
No.Delegates
shouldClose(self)
Called when user requests to close the window, should return whether the window can be closed.
Parameters
Windowself
Return
Boolean