Window

Native window.

Modulerequire("gui")
TypeClass
InheritsResponder

Class methods

create(options)

Create a new window with options.

Parameters

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

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

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

getContentSize()

Return the size of content view.

Return

SizeF

setBounds(bounds)

Change the position and size of the window.

Parameters

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

isVisible()

Return whether window is visible.

Return

Boolean

setAlwaysOnTop(top)

Make the window always show above other normal windows.

Parameters

isAlwaysOnTop()

Return whether window is always above other normal windows.

Return

Boolean

setFullscreen(fullscreen)

Enter/leave fullscreen state.

Parameters

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

isResizable()

Return whether window can be resized.

Return

Boolean

setMaximizable(maximizable)

Set whether window can be maximize.

Parameters

isMaximizable()

Return whether window can be maximize.

Return

Boolean

setMinimizable(minimizable)

Set whether window can be minimized.

Parameters

isMinimizable()

Return whether window can be minimized.

Return

Boolean

setMovable(movable)

Set whether window can be moved.

Parameters

isMovable()

Return whether window can be moved.

Return

Boolean

setTitle(title)

Set window title.

Parameters

getTitle()

Get window title.

Return

String

setBackgroundColor(color)

Set the background color of the window.

Parameters

getScaleFactor()

Return the scale factor of the window.

Return

Number

setToolbar(toolbar) macOS

Set the window toolbar.

Parameters

getToolbar() macOS

Return the window toolbar.

Return

Toolbar

setTitleVisible(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

isTitleVisible() macOS

Return whether title is visible.

Return

Boolean

setFullSizeContentView(full) macOS

Set the NSWindowStyleMaskFullSizeContentView style on the window.

Parameters

isFullSizeContentView() macOS

Return whether the window has NSWindowStyleMaskFullSizeContentView style.

Return

Boolean

setSkipTaskbar(skip) Windows Linux

Set whether to hide the window from taskbar.

Parameters

setIcon(icon) Windows Linux

Set the window icon.

Parameters

setMenuBar(menubar) Windows Linux

Set the window menu bar.

Parameters

getMenuBar() Windows Linux

Return the window menu bar.

Return

MenuBar

setMenuBarVisible(visible) Windows Linux

Set whether the window menu bar is visible.

The accelerators of menu items will still work when menu bar is hidden.

Calling setMenu will reset the menu bar to visible.

Parameters

getHWND() Windows

Return a Node.js Buffer containing the HWND of the native window.

Return

Buffer

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

removeChildWindow(child)

Remove this window as child's parent window.

Parameters

getChildWindows()

Return all the child windows of this window.

Return

Array

Events

onClose(self)

Emitted when the window is closed.

Parameters

Preventable

No.

onFocus(self)

Emitted when the window is focused.

Parameters

Preventable

No.

onBlur(self)

Emitted when the window lost focus.

Parameters

Preventable

No.

Delegates

shouldClose(self)

Called when user requests to close the window, should return whether the window can be closed.

Parameters

Return

Boolean