BaseWindow

Constructors

Link copied to clipboard
constructor(options: BaseWindowConstructorOptions = definedExternally)

BaseWindow

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

A string property that defines an alternative title provided only to accessibility tools such as screen readers. This string is not directly visible to users.

Link copied to clipboard
open val alwaysOnTopChangedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, Boolean>>
Link copied to clipboard
open val appCommandEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, String>>
Link copied to clipboard

A boolean property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single Alt key.

Link copied to clipboard
open val blurEvent: <Error class: unknown class><<Error class: unknown class><Event<*>>>
Link copied to clipboard
open var closable: Boolean

A boolean property that determines whether the window can be manually closed by user.

Link copied to clipboard
open val closedEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val closeEvent: <Error class: unknown class><<Error class: unknown class><Event<*>>>
Link copied to clipboard

A View property for the content view of the window.

Link copied to clipboard

A boolean property that specifies whether the window’s document has been edited.

Link copied to clipboard
open val enterFullScreenEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

A boolean property that determines whether the window is excluded from the application’s Windows menu. false by default.

Link copied to clipboard
open var focusable: Boolean

A boolean property that determines whether the window is focusable.

Link copied to clipboard
open val focusEvent: <Error class: unknown class><<Error class: unknown class><Event<*>>>
Link copied to clipboard

A boolean property that determines whether the window is in fullscreen mode.

Link copied to clipboard

A boolean property that determines whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

Link copied to clipboard
open val hideEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val id: Double

A Integer property representing the unique ID of the window. Each ID is unique among all BaseWindow instances of the entire Electron application.

Link copied to clipboard
open var kiosk: Boolean

A boolean property that determines whether the window is in kiosk mode.

Link copied to clipboard
open val leaveFullScreenEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

A boolean property that determines whether the window can be manually maximized by user.

Link copied to clipboard
open val maximizeEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

A boolean property that determines whether the menu bar should be visible.

Link copied to clipboard

A boolean property that determines whether the window can be manually minimized by user.

Link copied to clipboard
open val minimizeEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open var movable: Boolean

A boolean property that determines Whether the window can be moved by user.

Link copied to clipboard
open val movedEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val moveEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val newWindowForTabEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

A string property that determines the pathname of the file the window represents, and the icon of the file will show in window's title bar.

Link copied to clipboard
open var resizable: Boolean

A boolean property that determines whether the window can be manually resized by user.

Link copied to clipboard
open val resizedEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val resizeEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val restoreEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val rotateGestureEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, Double>>
Link copied to clipboard
open val sessionEndEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open var shadow: Boolean

A boolean property that determines whether the window has a shadow.

Link copied to clipboard
open val sheetBeginEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val sheetEndEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val showEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

A boolean property that determines whether the window is in simple (pre-Lion) fullscreen mode.

Link copied to clipboard
open val swipeEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, String>>
Link copied to clipboard
open val systemContextMenuEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, Point>>
Link copied to clipboard

A string (optional) property that is equal to the tabbingIdentifier passed to the BrowserWindow constructor or undefined if none was set.

Link copied to clipboard
open var title: String

A string property that determines the title of the native window.

Link copied to clipboard
open val unmaximizeEvent: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

A boolean property that determines whether the window is visible on all workspaces.

Link copied to clipboard
open val willMoveEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, Rectangle>>
Link copied to clipboard
open val willResizeEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, Rectangle, WillResizeDetails>>

Functions

Link copied to clipboard
fun addTabbedWindow(baseWindow: BaseWindow)

Adds a window as a tab on this window, after the tab for the window instance.

Link copied to clipboard
open fun blur()

Removes focus from the window.

Link copied to clipboard
open fun center()

Moves window to the center of the screen.

Link copied to clipboard
open fun close()

Try to close the window. This has the same effect as a user manually clicking the close button of the window. The web page may cancel the close though. See the close event.

Link copied to clipboard
open fun closeFilePreview()

Closes the currently open Quick Look panel.

Link copied to clipboard
open fun destroy()

Force closing the window, the unload and beforeunload event won't be emitted for the web page, and close event will also not be emitted for this window, but it guarantees the closed event will be emitted.

Link copied to clipboard
open fun flashFrame(flag: Boolean)

Starts or stops flashing the window to attract user's attention.

Link copied to clipboard
open fun focus()

Focuses on the window.

Link copied to clipboard

Gets the background color of the window in Hex (#RRGGBB) format.

Link copied to clipboard
open fun getBounds(): Rectangle

The bounds of the window as Object.

Link copied to clipboard
open fun getChildWindows(): <Error class: unknown class><BaseWindow>

All child windows.

Link copied to clipboard

The bounds of the window's client area as Object.

Link copied to clipboard
open fun getContentSize(): <Error class: unknown class><Double>

Contains the window's client area's width and height.

Link copied to clipboard

The content view of the window.

Link copied to clipboard
open fun getMaximumSize(): <Error class: unknown class><Double>

Contains the window's maximum width and height.

Link copied to clipboard

Window id in the format of DesktopCapturerSource's id. For example "window:1324:0".

Link copied to clipboard
open fun getMinimumSize(): <Error class: unknown class><Double>

Contains the window's minimum width and height.

Link copied to clipboard
open fun getNativeWindowHandle(): <Error class: unknown class><out <Error class: unknown class>>

The platform-specific handle of the window.

Link copied to clipboard

Contains the window bounds of the normal state

Link copied to clipboard
open fun getOpacity(): Double

between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns

Link copied to clipboard

The parent window or null if there is no parent.

Link copied to clipboard
open fun getPosition(): <Error class: unknown class><Double>

Contains the window's current position.

Link copied to clipboard

The pathname of the file the window represents.

Link copied to clipboard
open fun getSize(): <Error class: unknown class><Double>

Contains the window's width and height.

Link copied to clipboard
open fun getTitle(): String

The title of the native window.

Link copied to clipboard

The custom position for the traffic light buttons in frameless window, null will be returned when there is no custom position.

Link copied to clipboard
open fun hasShadow(): Boolean

Whether the window has a shadow.

Link copied to clipboard
open fun hide()

Hides the window.

Link copied to clipboard
open fun hookWindowMessage(    message: Double,     callback: (<Error class: unknown class><out <Error class: unknown class>>, <Error class: unknown class><out <Error class: unknown class>>) -> Unit)

Hooks a windows message. The callback is called when the message is received in the WndProc.

Link copied to clipboard
open fun invalidateShadow()

Invalidates the window shadow so that it is recomputed based on the current window shape.

Link copied to clipboard

Whether the window is always on top of other windows.

Link copied to clipboard
open fun isClosable(): Boolean

Whether the window can be manually closed by user.

Link copied to clipboard
open fun isDestroyed(): Boolean

Whether the window is destroyed.

Link copied to clipboard

Whether the window's document has been edited.

Link copied to clipboard
open fun isEnabled(): Boolean

whether the window is enabled.

Link copied to clipboard
open fun isFocusable(): Boolean

Whether the window can be focused.

Link copied to clipboard
open fun isFocused(): Boolean

Whether the window is focused.

Link copied to clipboard
open fun isFullScreen(): Boolean

Whether the window is in fullscreen mode.

Link copied to clipboard

Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

Link copied to clipboard

Whether the window will be hidden when the user toggles into mission control.

Link copied to clipboard
open fun isKiosk(): Boolean

Whether the window is in kiosk mode.

Link copied to clipboard

Whether the window can be manually maximized by user.

Link copied to clipboard
open fun isMaximized(): Boolean

Whether the window is maximized.

Link copied to clipboard

Whether menu bar automatically hides itself.

Link copied to clipboard

Whether the menu bar is visible.

Link copied to clipboard

Whether the window can be manually minimized by the user.

Link copied to clipboard
open fun isMinimized(): Boolean

Whether the window is minimized.

Link copied to clipboard
open fun isModal(): Boolean

Whether current window is a modal window.

Link copied to clipboard
open fun isMovable(): Boolean

Whether the window can be moved by user.

Link copied to clipboard
open fun isNormal(): Boolean

Whether the window is in normal state (not maximized, not minimized, not in fullscreen mode).

Link copied to clipboard
open fun isResizable(): Boolean

Whether the window can be manually resized by the user.

Link copied to clipboard

Whether the window is in simple (pre-Lion) fullscreen mode.

Link copied to clipboard
open fun isTabletMode(): Boolean

Whether the window is in Windows 10 tablet mode.

Link copied to clipboard
open fun isVisible(): Boolean

Whether the window is visible to the user in the foreground of the app.

Link copied to clipboard

Whether the window is visible on all workspaces.

Link copied to clipboard

true or false depending on whether the message is hooked.

Link copied to clipboard
open fun maximize()

Maximizes the window. This will also show (but not focus) the window if it isn't being displayed already.

Link copied to clipboard
open fun mergeAllWindows()

Merges all windows into one window with multiple tabs when native tabs are enabled and there is more than one open window.

Link copied to clipboard
open fun minimize()

Minimizes the window. On some platforms the minimized window will be shown in the Dock.

Link copied to clipboard
open fun moveAbove(mediaSourceId: String)

Moves window above the source window in the sense of z-order. If the mediaSourceId is not of type window or if the window does not exist then this method throws an error.

Link copied to clipboard

Moves the current tab into a new window if native tabs are enabled and there is more than one tab in the current window.

Link copied to clipboard
open fun moveTop()

Moves window to top(z-order) regardless of focus

Link copied to clipboard
open fun previewFile(path: String, displayName: String = definedExternally)

Uses Quick Look to preview a file at a given path.

Link copied to clipboard
open fun removeMenu()

Remove the window's menu bar.

Link copied to clipboard
open fun restore()

Restores the window from minimized state to its previous state.

Link copied to clipboard
open fun selectNextTab()

Selects the next tab when native tabs are enabled and there are other tabs in the window.

Link copied to clipboard

Selects the previous tab when native tabs are enabled and there are other tabs in the window.

Link copied to clipboard
fun setAlwaysOnTop(flag: Boolean, level: BaseWindowSetAlwaysOnTopLevel = definedExternally, relativeLevel: Double = definedExternally)

Sets whether the window should show always on top of other windows. After setting this, the window is still a normal window, not a toolbox window which can not be focused on.

Link copied to clipboard
open fun setAppDetails(options: AppDetailsOptions)

Sets the properties for the window's taskbar button.

Link copied to clipboard
open fun setAspectRatio(aspectRatio: Double, extraSize: Size = definedExternally)

This will make a window maintain an aspect ratio. The extra size allows a developer to have space, specified in pixels, not included within the aspect ratio calculations. This API already takes into account the difference between a window's size and its content size.

Link copied to clipboard
open fun setAutoHideCursor(autoHide: Boolean)

Controls whether to hide cursor when typing.

Link copied to clipboard
open fun setAutoHideMenuBar(hide: Boolean)

Sets whether the window menu bar should hide itself automatically. Once set the menu bar will only show when users press the single Alt key.

Link copied to clipboard
open fun setBackgroundColor(backgroundColor: String)

Examples of valid backgroundColor values:

Link copied to clipboard

This method sets the browser window's system-drawn background material, including behind the non-client area.

Link copied to clipboard
open fun setBounds(bounds: Rectangle, animate: Boolean = definedExternally)

Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.

Link copied to clipboard
open fun setClosable(closable: Boolean)

Sets whether the window can be manually closed by user. On Linux does nothing.

Link copied to clipboard
open fun setContentBounds(bounds: Rectangle, animate: Boolean = definedExternally)

Resizes and moves the window's client area (e.g. the web page) to the supplied bounds.

Link copied to clipboard
open fun setContentProtection(enable: Boolean)

Prevents the window contents from being captured by other apps.

Link copied to clipboard
open fun setContentSize(width: Double, height: Double, animate: Boolean = definedExternally)

Resizes the window's client area (e.g. the web page) to width and height.

Link copied to clipboard
fun setContentView(view: View)

Sets the content view of the window.

Link copied to clipboard
open fun setDocumentEdited(edited: Boolean)

Specifies whether the window’s document has been edited, and the icon in title bar will become gray when set to true.

Link copied to clipboard
open fun setEnabled(enable: Boolean)

Disable or enable the window.

Link copied to clipboard
open fun setFocusable(focusable: Boolean)

Changes whether the window can be focused.

Link copied to clipboard
open fun setFullScreen(flag: Boolean)

Sets whether the window should be in fullscreen mode.

Link copied to clipboard
open fun setFullScreenable(fullscreenable: Boolean)

Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

Link copied to clipboard
open fun setHasShadow(hasShadow: Boolean)

Sets whether the window should have a shadow.

Link copied to clipboard

Sets whether the window will be hidden when the user toggles into mission control.

Link copied to clipboard
open fun setIcon(icon: NativeImage)
open fun setIcon(icon: String)

Changes window icon.

Link copied to clipboard
open fun setIgnoreMouseEvents(ignore: Boolean, options: IgnoreMouseEventsOptions = definedExternally)

Makes the window ignore all mouse events.

Link copied to clipboard
open fun setKiosk(flag: Boolean)

Enters or leaves kiosk mode.

Link copied to clipboard
open fun setMaximizable(maximizable: Boolean)

Sets whether the window can be manually maximized by user. On Linux does nothing.

Link copied to clipboard
open fun setMaximumSize(width: Double, height: Double)

Sets the maximum size of window to width and height.

Link copied to clipboard
open fun setMenu(menu: Menu?)

Sets the menu as the window's menu bar.

Link copied to clipboard
open fun setMenuBarVisibility(visible: Boolean)

Sets whether the menu bar should be visible. If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single Alt key.

Link copied to clipboard
open fun setMinimizable(minimizable: Boolean)

Sets whether the window can be manually minimized by user. On Linux does nothing.

Link copied to clipboard
open fun setMinimumSize(width: Double, height: Double)

Sets the minimum size of window to width and height.

Link copied to clipboard
open fun setMovable(movable: Boolean)

Sets whether the window can be moved by user. On Linux does nothing.

Link copied to clipboard
open fun setOpacity(opacity: Double)

Sets the opacity of the window. On Linux, does nothing. Out of bound number values are clamped to the 0, 1 range.

Link copied to clipboard
open fun setOverlayIcon(overlay: NativeImage?, description: String)

Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to convey some sort of application status or to passively notify the user.

Link copied to clipboard

Sets parent as current window's parent window, passing null will turn current window into a top-level window.

Link copied to clipboard
open fun setPosition(x: Double, y: Double, animate: Boolean = definedExternally)

Moves window to x and y.

Link copied to clipboard
open fun setProgressBar(progress: Double, options: ProgressBarOptions = definedExternally)

Sets progress value in progress bar. Valid range is 0, 1.0.

Link copied to clipboard
open fun setRepresentedFilename(filename: String)

Sets the pathname of the file the window represents, and the icon of the file will show in window's title bar.

Link copied to clipboard
open fun setResizable(resizable: Boolean)

Sets whether the window can be manually resized by the user.

Link copied to clipboard
open fun setShape(rects: <Error class: unknown class><Rectangle>)

Setting a window shape determines the area within the window where the system permits drawing and user interaction. Outside of the given region, no pixels will be drawn and no mouse events will be registered. Mouse events outside of the region will not be received by that window, but will fall through to whatever is behind the window.

Link copied to clipboard
open fun setSheetOffset(offsetY: Double, offsetX: Double = definedExternally)

Changes the attachment point for sheets on macOS. By default, sheets are attached just below the window frame, but you may want to display them beneath a HTML-rendered toolbar. For example:

Link copied to clipboard

Enters or leaves simple fullscreen mode.

Link copied to clipboard
open fun setSize(width: Double, height: Double, animate: Boolean = definedExternally)

Resizes the window to width and height. If width or height are below any set minimum size constraints the window will snap to its minimum size.

Link copied to clipboard
open fun setSkipTaskbar(skip: Boolean)

Makes the window not show in the taskbar.

Link copied to clipboard
open fun setThumbarButtons(buttons: <Error class: unknown class><ThumbarButton>): Boolean

Whether the buttons were added successfully

Link copied to clipboard
open fun setThumbnailClip(region: Rectangle)

Sets the region of the window to show as the thumbnail image displayed when hovering over the window in the taskbar. You can reset the thumbnail to be the entire window by specifying an empty region: { x: 0, y: 0, width: 0, height: 0 }.

Link copied to clipboard
open fun setThumbnailToolTip(toolTip: String)

Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar.

Link copied to clipboard
open fun setTitle(title: String)

Changes the title of native window to title.

Link copied to clipboard

On a Window with Window Controls Overlay already enabled, this method updates the style of the title bar overlay.

Link copied to clipboard
open fun setTouchBar(touchBar: TouchBar?)

Sets the touchBar layout for the current window. Specifying null or undefined clears the touch bar. This method only has an effect if the machine has a touch bar.

Link copied to clipboard

Adds a vibrancy effect to the window. Passing null or an empty string will remove the vibrancy effect on the window.

Link copied to clipboard
open fun setVisibleOnAllWorkspaces(visible: Boolean, options: VisibleOnAllWorkspacesOptions = definedExternally)

Sets whether the window should be visible on all workspaces.

Link copied to clipboard
open fun setWindowButtonPosition(position: Point?)

Set a custom position for the traffic light buttons in frameless window. Passing null will reset the position to default.

Link copied to clipboard

Sets whether the window traffic light buttons should be visible.

Link copied to clipboard
open fun show()

Shows and gives focus to the window.

Link copied to clipboard
open fun showAllTabs()

Shows or hides the tab overview when native tabs are enabled.

Link copied to clipboard
open fun showInactive()

Shows the window but doesn't focus on it.

Link copied to clipboard
open fun toggleTabBar()

Toggles the visibility of the tab bar if native tabs are enabled and there is only one tab in the current window.

Link copied to clipboard

Unhooks all of the window messages.

Link copied to clipboard
open fun unhookWindowMessage(message: Double)

Unhook the window message.

Link copied to clipboard
open fun unmaximize()

Unmaximizes the window.