Window
Native window.
Module | require("gui") |
Type | Class |
Class methods
create(options)
Create a new window with options
.
Parameters
Window::Options
options
Return
Window
Methods
close()
Request to close the window.
hasFrame()
Return whether window has a native frame.
Return
Boolean
isTransparent()
Return whether window is transparent.
Return
Boolean
setHasShadow(has)
Set whether window should have shadow.
Depending on platform, this may not work.
Parameters
Boolean
has
hasShadow()
Return whether window has shadow.
Return
Boolean
setContentView(view)
Set the content view of the window.
The content view will always be resized to fill window's client area.
Parameters
View
view
getContentView()
Return the content view of the window.
Return
View
center()
Move the window to the center of the screen.
setContentSize(size)
Resize window to make the content view fit size
.
Parameters
SizeF
size
getContentSize()
Return the size of content view.
Return
SizeF
setBounds(bounds)
Change the position and size of the window.
Parameters
RectF
bounds
getBounds()
Return the position and size of the window.
Return
RectF
setSizeConstraints(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
Boolean
setVisible(visible)
Show/hide the window.
Parameters
Boolean
visible
isVisible()
Return whether window is visible.
Return
Boolean
setAlwaysOnTop(top)
Make the window always show above other normal windows.
Parameters
Boolean
top
isAlwaysOnTop()
Return whether window is always above other normal windows.
Return
Boolean
setFullscreen(fullscreen)
Enter/leave fullscreen state.
Parameters
Boolean
fullscreen
isFullscreen()
Return whether window is in fullscreen.
Return
Boolean
maximize()
Maximize the window.
unmaximize()
Unmaximize the window.
isMaximized()
Return whether window is maximized.
Return
Boolean
minimize()
Minimize the window.
restore()
Restore the minimized window.
isMinimized()
Return whether window is minimized.
Return
Boolean
setResizable(resizable)
Set whether window can be resized.
Parameters
Boolean
resizable
isResizable()
Return whether window can be resized.
Return
Boolean
setMaximizable(maximizable)
Set whether window can be maximize.
Parameters
Boolean
maximizable
isMaximizable()
Return whether window can be maximize.
Return
Boolean
setMinimizable(minimizable)
Set whether window can be minimized.
Parameters
Boolean
minimizable
isMinimizable()
Return whether window can be minimized.
Return
Boolean
setMovable(movable)
Set whether window can be moved.
Parameters
Boolean
movable
isMovable()
Return whether window can be moved.
Return
Boolean
setTitle(title)
Set window title.
Parameters
String
title
getTitle()
Get window title.
Return
String
setBackgroundColor(color)
Set the background color of the window.
Parameters
Color
color
macOS
setToolbar(toolbar)Set the window toolbar.
Parameters
Toolbar
toolbar
macOS
getToolbar()Return the window toolbar.
Return
Toolbar
macOS
setTitleVisible(visible)Set whether the title is visible, when title was hidden the toolber would be moved into the area previously occupied by the title.
Parameters
Boolean
visible
macOS
isTitleVisible()Return whether title is visible.
Return
Boolean
macOS
setFullSizeContentView(full)Set the NSFullSizeContentViewWindowMask
style on the window.
Parameters
Boolean
full
macOS
isFullSizeContentView()Return whether the window has NSFullSizeContentViewWindowMask
style.
Return
Boolean
Windows Linux
setSkipTaskbar(skip)Set whether to hide the window from taskbar.
Parameters
Boolean
skip
Windows Linux
setIcon(icon)Set the window icon.
Parameters
Image
icon
Windows Linux
setMenuBar(menubar)Set the window menu bar.
Parameters
MenuBar
menubar
Windows Linux
getMenuBar()Return the window menu bar.
Return
MenuBar
getParentWindow()
Return the parent window.
Return
Window
addChildWindow(child)
Make child
a child window of this window.
This method will do nothing if child
already has a parent window.
Parameters
Window
child
removeChildWindow(child)
Remove this window as child
's parent window.
Parameters
Window
child
getChildWindows()
Return all the child windows of this window.
Return
Array
Events
onClose(self)
Emitted when the window is closed.
Parameters
Window
self
Preventable
No.onFocus(self)
Emitted when the window is focused.
Parameters
Window
self
Preventable
No.onBlur(self)
Emitted when the window lost focus.
Parameters
Window
self
Preventable
No.Delegates
shouldClose(self)
Called when user requests to close the window, should return whether the window can be closed.
Parameters
Window
self
Return
Boolean