Header menu logo fable-electron-docs-api

BrowserWindow Type

⚠ Process Availability: Main ✔ | Renderer ❌ | Utility ❌ | Exported ✔

Create and control browser windows.Process: MainThis module cannot be used until the ready event of the app module is emitted.### Window customizationThe BrowserWindow class exposes various ways to modify the look and behavior of your app's windows. For more details, see the Window Customization tutorial.### Showing the window gracefullyWhen loading a page in the window directly, users may see the page load incrementally, which is not a good experience for a native app. To make the window display without a visual flash, there are two solutions for different situations.### Using the ready-to-show eventWhile loading the page, the ready-to-show event will be emitted when the renderer process has rendered the page for the first time if the window has not been shown yet. Showing the window after this event will have no visual flash:const { BrowserWindow } = require('electron')const win = new BrowserWindow({ show: false })win.once('ready-to-show', () => { win.show()})This event is usually emitted after the did-finish-load event, but for pages with many remote resources, it may be emitted before the did-finish-load event.Please note that using this event implies that the renderer will be considered "visible" and paint even though show is false. This event will never fire if you use paintWhenInitiallyHidden: false### Setting the backgroundColor propertyFor a complex app, the ready-to-show event could be emitted too late, making the app feel slow. In this case, it is recommended to show the window immediately, and use a backgroundColor close to your app's background:const { BrowserWindow } = require('electron')const win = new BrowserWindow({ backgroundColor: '#2e2c29' })win.loadURL('https://github.com')Note that even for apps that use ready-to-show event, it is still recommended to set backgroundColor to make the app feel more native.Some examples of valid backgroundColor values include:const win = new BrowserWindow()win.setBackgroundColor('hsl(230, 100%, 50%)')win.setBackgroundColor('rgb(255, 145, 145)')win.setBackgroundColor('#ff00a3')win.setBackgroundColor('blueviolet')For more information about these color types see valid options in win.setBackgroundColor.### Parent and child windowsBy using parent option, you can create child windows:const { BrowserWindow } = require('electron')const top = new BrowserWindow()const child = new BrowserWindow({ parent: top })child.show()top.show()The child window will always show on top of the top window.### Modal windowsA modal window is a child window that disables parent window. To create a modal window, you have to set both the parent and modal options:const { BrowserWindow } = require('electron')const top = new BrowserWindow()const child = new BrowserWindow({ parent: top, modal: true, show: false })child.loadURL('https://github.com')child.once('ready-to-show', () => { child.show()})### Page visibilityThe Page Visibility API works as follows:* On all platforms, the visibility state tracks whether the window is hidden/minimized or not.* Additionally, on macOS, the visibility state also tracks the window occlusion state. If the window is occluded (i.e. fully covered) by another window, the visibility state will be hidden. On other platforms, the visibility state will be hidden only when the window is minimized or explicitly hidden with win.hide().* If a BrowserWindow is created with show: false, the initial visibility state will be visible despite the window actually being hidden.* If backgroundThrottling is disabled, the visibility state will remain visible even if the window is minimized, occluded, or hidden.It is recommended that you pause expensive operations when the visibility state is hidden in order to minimize power consumption.### Platform notices* On macOS modal windows will be displayed as sheets attached to the parent window.* On macOS the child windows will keep the relative position to parent window when parent window moves, while on Windows and Linux child windows will not move.* On Linux the type of modal windows will be changed to dialog.* On Linux many desktop environments do not support hiding a modal window.* On Wayland (Linux) it is generally not possible to programmatically resize windows after creation, or to position, move, focus, or blur windows without user input. If your app needs these capabilities, run it in Xwayland by appending the flag --ozone-platform=x11.### Class: BrowserWindow extends BaseWindow> Create and control browser windows.Process: MainBrowserWindow is an EventEmitter.It creates a new BrowserWindow with native properties as set by the options.> [!WARNING] Electron's built-in classes cannot be subclassed in user code. For more information, see the FAQ.

Constructors

Constructor Description

BrowserWindow(?options)

Full Usage: BrowserWindow(?options)

Parameters:
Returns: BrowserWindow

Instance members

Instance member Description

this.accessibleTitle

Full Usage: this.accessibleTitle

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.

this.addTabbedWindow browserWindow

Full Usage: this.addTabbedWindow browserWindow

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

browserWindow : BrowserWindow

this.autoHideMenuBar

Full Usage: this.autoHideMenuBar

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌ 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.If the menu bar is already visible, setting this property to true won't hide it immediately.

this.blur ()

Full Usage: this.blur ()

Modifiers: inline

Removes focus from the window.Not supported on Wayland (Linux).

this.blurWebView ()

Full Usage: this.blurWebView ()

Modifiers: inline

this.capturePage (?rect, ?stayHidden, ?stayAwake)

Full Usage: this.capturePage (?rect, ?stayHidden, ?stayAwake)

Parameters:
    ?rect : Rectangle
    ?stayHidden : bool
    ?stayAwake : bool

Returns: Promise<NativeImage>
Modifiers: inline

Resolves with a NativeImageCaptures a snapshot of the page within rect. Omitting rect will capture the whole visible page. If the page is not visible, rect may be empty. The page is considered visible when its browser window is hidden and the capturer count is non-zero. If you would like the page to stay hidden, you should ensure that stayHidden is set to true.

?rect : Rectangle
?stayHidden : bool
?stayAwake : bool
Returns: Promise<NativeImage>

this.center ()

Full Usage: this.center ()

Modifiers: inline

Moves window to the center of the screen.Not supported on Wayland (Linux).

this.closable

Full Usage: this.closable

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that determines whether the window can be manually closed by user.On Linux the setter is a no-op, although the getter returns true.

this.close ()

Full Usage: this.close ()

Modifiers: inline

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.

this.closeFilePreview ()

Full Usage: this.closeFilePreview ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Closes the currently open Quick Look panel.

this.contentView

Full Usage: this.contentView

A View property for the content view of the window.

this.destroy ()

Full Usage: this.destroy ()

Modifiers: inline

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.

this.documentEdited

Full Usage: this.documentEdited

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that specifies whether the window’s document has been edited.The icon in title bar will become gray when set to true.

this.excludedFromShownWindowsMenu

Full Usage: this.excludedFromShownWindowsMenu

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that determines whether the window is excluded from the application’s Windows menu. false by default.

this.flashFrame flag

Full Usage: this.flashFrame flag

Parameters:
    flag : bool

Modifiers: inline

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

flag : bool

this.focus ()

Full Usage: this.focus ()

Modifiers: inline

Focuses on the window.On Wayland (Linux), the desktop environment may show a notification or flash the app icon if the window or app is not already focused.

this.focusOnWebView ()

Full Usage: this.focusOnWebView ()

Modifiers: inline

this.focusable

Full Usage: this.focusable

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that determines whether the window is focusable.

this.fullScreen

Full Usage: this.fullScreen

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

this.fullScreenable

Full Usage: this.fullScreenable

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

this.getAccentColor ()

Full Usage: this.getAccentColor ()

Returns: U2<string, bool>
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

the system accent color and highlighting of active window border in Hex RGB format.If a color has been set for the window that differs from the system accent color, the window accent color will be returned. Otherwise, a boolean will be returned, with true indicating that the window uses the global system accent color, and false indicating that accent color highlighting is disabled for this window.

Returns: U2<string, bool>

this.getBackgroundColor ()

Full Usage: this.getBackgroundColor ()

Returns: string
Modifiers: inline

Gets the background color of the window in Hex (#RRGGBB) format.See Setting backgroundColor.> [!NOTE] The alpha value is not returned alongside the red, green, and blue values.

Returns: string

this.getBounds ()

Full Usage: this.getBounds ()

Returns: Rectangle
Modifiers: inline

The bounds of the window as Object.> [!NOTE] On macOS, the y-coordinate value returned will be at minimum the Tray height. For example, calling win.setBounds({ x: 25, y: 20, width: 800, height: 600 }) with a tray height of 38 means that win.getBounds() will return { x: 25, y: 38, width: 800, height: 600 }.

Returns: Rectangle

this.getChildWindows ()

Full Usage: this.getChildWindows ()

Returns: BrowserWindow[]
Modifiers: inline

All child windows.

Returns: BrowserWindow[]

this.getContentBounds ()

Full Usage: this.getContentBounds ()

Returns: Rectangle
Modifiers: inline

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

Returns: Rectangle

this.getContentSize ()

Full Usage: this.getContentSize ()

Returns: int[]
Modifiers: inline

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

Returns: int[]

this.getContentView ()

Full Usage: this.getContentView ()

Returns: View
Modifiers: inline

The content view of the window.

Returns: View

this.getMaximumSize ()

Full Usage: this.getMaximumSize ()

Returns: int[]
Modifiers: inline

Contains the window's maximum width and height.

Returns: int[]

this.getMediaSourceId ()

Full Usage: this.getMediaSourceId ()

Returns: string
Modifiers: inline

Window id in the format of DesktopCapturerSource's id. For example "window:1324:0".More precisely the format is window:id:other_id where id is HWND on Windows, CGWindowID (uint64_t) on macOS and Window (unsigned long) on Linux. other_id is used to identify web contents (tabs) so within the same top level window.

Returns: string

this.getMinimumSize ()

Full Usage: this.getMinimumSize ()

Returns: int[]
Modifiers: inline

Contains the window's minimum width and height.

Returns: int[]

this.getNativeWindowHandle ()

Full Usage: this.getNativeWindowHandle ()

Returns: Buffer
Modifiers: inline

The platform-specific handle of the window.The native type of the handle is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.

Returns: Buffer

this.getNormalBounds ()

Full Usage: this.getNormalBounds ()

Returns: Rectangle
Modifiers: inline

Contains the window bounds of the normal state> [!NOTE] Whatever the current state of the window (maximized, minimized or in fullscreen), this function always returns the position and size of the window in normal state. In normal state, getBounds and getNormalBounds return the same Rectangle.

Returns: Rectangle

this.getOpacity ()

Full Usage: this.getOpacity ()

Returns: float
Modifiers: inline

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

Returns: float

this.getParentWindow ()

Full Usage: this.getParentWindow ()

Returns: Option<BrowserWindow>
Modifiers: inline

The parent window or null if there is no parent.

Returns: Option<BrowserWindow>

this.getPosition ()

Full Usage: this.getPosition ()

Returns: int[]
Modifiers: inline

Contains the window's current position.

Returns: int[]

this.getRepresentedFilename ()

Full Usage: this.getRepresentedFilename ()

Returns: string
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

The pathname of the file the window represents.

Returns: string

this.getSize ()

Full Usage: this.getSize ()

Returns: int[]
Modifiers: inline

Contains the window's width and height.

Returns: int[]

this.getTitle ()

Full Usage: this.getTitle ()

Returns: string
Modifiers: inline

The title of the native window.> [!NOTE] The title of the web page can be different from the title of the native window.

Returns: string

this.getWindowButtonPosition ()

Full Usage: this.getWindowButtonPosition ()

Returns: Option<Point>
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

Returns: Option<Point>

this.hasShadow ()

Full Usage: this.hasShadow ()

Returns: bool
Modifiers: inline

Whether the window has a shadow.

Returns: bool

this.hide ()

Full Usage: this.hide ()

Modifiers: inline

Hides the window.

this.hookWindowMessage (message, callback)

Full Usage: this.hookWindowMessage (message, callback)

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

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

message : int
callback : Buffer * Buffer -> unit

this.id

Full Usage: this.id

Returns: int

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

Returns: int

this.invalidateShadow ()

Full Usage: this.invalidateShadow ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Invalidates the window shadow so that it is recomputed based on the current window shape.BrowserWindows that are transparent can sometimes leave behind visual artifacts on macOS. This method can be used to clear these artifacts when, for example, performing an animation.

this.isAlwaysOnTop ()

Full Usage: this.isAlwaysOnTop ()

Returns: bool
Modifiers: inline

Whether the window is always on top of other windows.

Returns: bool

this.isClosable ()

Full Usage: this.isClosable ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Whether the window can be manually closed by user.On Linux always returns true.

Returns: bool

this.isContentProtected ()

Full Usage: this.isContentProtected ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

whether or not content protection is currently enabled.

Returns: bool

this.isDestroyed ()

Full Usage: this.isDestroyed ()

Returns: bool
Modifiers: inline

Whether the window is destroyed.

Returns: bool

this.isDocumentEdited ()

Full Usage: this.isDocumentEdited ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Whether the window's document has been edited.

Returns: bool

this.isEnabled ()

Full Usage: this.isEnabled ()

Returns: bool
Modifiers: inline

whether the window is enabled.

Returns: bool

this.isFocusable ()

Full Usage: this.isFocusable ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Whether the window can be focused.

Returns: bool

this.isFocused ()

Full Usage: this.isFocused ()

Returns: bool
Modifiers: inline

Whether the window is focused.

Returns: bool

this.isFullScreen ()

Full Usage: this.isFullScreen ()

Returns: bool
Modifiers: inline

Whether the window is in fullscreen mode.> [!NOTE] On macOS, fullscreen transitions take place asynchronously. When querying for a BrowserWindow's fullscreen status, you should ensure that either the 'enter-full-screen' or 'leave-full-screen' events have been emitted.

Returns: bool

this.isFullScreenable ()

Full Usage: this.isFullScreenable ()

Returns: bool
Modifiers: inline

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

Returns: bool

this.isHiddenInMissionControl ()

Full Usage: this.isHiddenInMissionControl ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

Returns: bool

this.isKiosk ()

Full Usage: this.isKiosk ()

Returns: bool
Modifiers: inline

Whether the window is in kiosk mode.

Returns: bool

this.isMaximizable ()

Full Usage: this.isMaximizable ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Whether the window can be manually maximized by user.On Linux always returns true.

Returns: bool

this.isMaximized ()

Full Usage: this.isMaximized ()

Returns: bool
Modifiers: inline

Whether the window is maximized.

Returns: bool

this.isMenuBarAutoHide ()

Full Usage: this.isMenuBarAutoHide ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Whether menu bar automatically hides itself.

Returns: bool

this.isMenuBarVisible ()

Full Usage: this.isMenuBarVisible ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Whether the menu bar is visible.

Returns: bool

this.isMinimizable ()

Full Usage: this.isMinimizable ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Whether the window can be manually minimized by the user.On Linux always returns true.

Returns: bool

this.isMinimized ()

Full Usage: this.isMinimized ()

Returns: bool
Modifiers: inline

Whether the window is minimized.

Returns: bool

this.isModal ()

Full Usage: this.isModal ()

Returns: bool
Modifiers: inline

Whether current window is a modal window.

Returns: bool

this.isMovable ()

Full Usage: this.isMovable ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Whether the window can be moved by user.On Linux always returns true.

Returns: bool

this.isNormal ()

Full Usage: this.isNormal ()

Returns: bool
Modifiers: inline

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

Returns: bool

this.isResizable ()

Full Usage: this.isResizable ()

Returns: bool
Modifiers: inline

Whether the window can be manually resized by the user.

Returns: bool

this.isSimpleFullScreen ()

Full Usage: this.isSimpleFullScreen ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

Returns: bool

this.isSnapped ()

Full Usage: this.isSnapped ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

whether the window is arranged via Snap.The window is snapped via buttons shown when the mouse is hovered over window maximize button, or by dragging it to the edges of the screen.

Returns: bool

this.isTabletMode ()

Full Usage: this.isTabletMode ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Whether the window is in Windows 10 tablet mode.Since Windows 10 users can use their PC as tablet, under this mode apps can choose to optimize their UI for tablets, such as enlarging the titlebar and hiding titlebar buttons.This API returns whether the window is in tablet mode, and the resize event can be be used to listen to changes to tablet mode.

Returns: bool

this.isVisible ()

Full Usage: this.isVisible ()

Returns: bool
Modifiers: inline

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

Returns: bool

this.isVisibleOnAllWorkspaces ()

Full Usage: this.isVisibleOnAllWorkspaces ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ✔ | MAS ❌

Whether the window is visible on all workspaces.> [!NOTE] This API always returns false on Windows.

Returns: bool

this.isWindowMessageHooked message

Full Usage: this.isWindowMessageHooked message

Parameters:
    message : int

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌ true or false depending on whether the message is hooked.

message : int
Returns: bool

this.kiosk

Full Usage: this.kiosk

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

this.loadFile (filePath, ?query, ?search, ?hash)

Full Usage: this.loadFile (filePath, ?query, ?search, ?hash)

Parameters:
    filePath : string
    ?query : Record<string, string>
    ?search : string
    ?hash : string

Returns: Promise<unit>
Modifiers: inline

the promise will resolve when the page has finished loading (see did-finish-load), and rejects if the page fails to load (see did-fail-load).Same as webContents.loadFile, filePath should be a path to an HTML file relative to the root of your application. See the webContents docs for more information.

filePath : string
?query : Record<string, string>
?search : string
?hash : string
Returns: Promise<unit>

this.loadURL (url, ?httpReferrer, ?userAgent, ?extraHeaders, ?postData, ?baseURLForDataURL)

Full Usage: this.loadURL (url, ?httpReferrer, ?userAgent, ?extraHeaders, ?postData, ?baseURLForDataURL)

Parameters:
Returns: Promise<unit>
Modifiers: inline

the promise will resolve when the page has finished loading (see did-finish-load), and rejects if the page fails to load (see did-fail-load).Same as webContents.loadURL(url[, options]).The url can be a remote address (e.g. http://) or a path to a local HTML file using the file:// protocol.To ensure that file URLs are properly formatted, it is recommended to use Node's url.format method:You can load a URL using a POST request with URL-encoded data by doing the following:

url : string
?httpReferrer : U2<string, Referrer>
?userAgent : string
?extraHeaders : string
?postData : U2<UploadRawData, UploadFile>[]
?baseURLForDataURL : string
Returns: Promise<unit>

this.maximizable

Full Usage: this.maximizable

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that determines whether the window can be manually maximized by user.On Linux the setter is a no-op, although the getter returns true.

this.maximize ()

Full Usage: this.maximize ()

Modifiers: inline

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

this.menuBarVisible

Full Usage: this.menuBarVisible

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌ A boolean property that determines whether the menu bar should be visible.> [!NOTE] If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single Alt key.

this.mergeAllWindows ()

Full Usage: this.mergeAllWindows ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

this.minimizable

Full Usage: this.minimizable

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that determines whether the window can be manually minimized by user.On Linux the setter is a no-op, although the getter returns true.

this.minimize ()

Full Usage: this.minimize ()

Modifiers: inline

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

this.movable

Full Usage: this.movable

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that determines Whether the window can be moved by user.On Linux the setter is a no-op, although the getter returns true.

this.moveAbove mediaSourceId

Full Usage: this.moveAbove mediaSourceId

Parameters:
    mediaSourceId : string

Modifiers: inline

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.

mediaSourceId : string

this.moveTabToNewWindow ()

Full Usage: this.moveTabToNewWindow ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

this.moveTop ()

Full Usage: this.moveTop ()

Modifiers: inline

Moves window to top(z-order) regardless of focus.Not supported on Wayland (Linux).

this.offAlwaysOnTopChanged handler

Full Usage: this.offAlwaysOnTopChanged handler

Parameters:
Modifiers: inline

Emitted when the window is set or unset to show always on top of other windows.

handler : IOnAlwaysOnTopChanged -> unit

this.offAlwaysOnTopChanged handler

Full Usage: this.offAlwaysOnTopChanged handler

Parameters:
    handler : Event -> bool -> unit

Modifiers: inline

Emitted when the window is set or unset to show always on top of other windows.

handler : Event -> bool -> unit

this.offAppCommand handler

Full Usage: this.offAppCommand handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when an App Command is invoked. These are typically related to keyboard media keys or browser commands, as well as the "Back" button built into some mice on Windows.Commands are lowercased, underscores are replaced with hyphens, and the APPCOMMAND_ prefix is stripped off. e.g. APPCOMMAND_BROWSER_BACKWARD is emitted as browser-backward.The following app commands are explicitly supported on Linux:* browser-backward* browser-forward

handler : IOnAppCommand -> unit

this.offAppCommand handler

Full Usage: this.offAppCommand handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when an App Command is invoked. These are typically related to keyboard media keys or browser commands, as well as the "Back" button built into some mice on Windows.Commands are lowercased, underscores are replaced with hyphens, and the APPCOMMAND_ prefix is stripped off. e.g. APPCOMMAND_BROWSER_BACKWARD is emitted as browser-backward.The following app commands are explicitly supported on Linux:* browser-backward* browser-forward

handler : Event -> string -> unit

this.offBlur handler

Full Usage: this.offBlur handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window loses focus.

handler : unit -> unit

this.offClose handler

Full Usage: this.offClose handler

Parameters:
    handler : Event -> unit

Modifiers: inline

Emitted when the window is going to be closed. It's emitted before the beforeunload and unload event of the DOM. Calling event.preventDefault() will cancel the close.Usually you would want to use the beforeunload handler to decide whether the window should be closed, which will also be called when the window is reloaded. In Electron, returning any value other than undefined would cancel the close. For example:> [!NOTE] There is a subtle difference between the behaviors of window.onbeforeunload = handler and window.addEventListener('beforeunload', handler). It is recommended to always set the event.returnValue explicitly, instead of only returning a value, as the former works more consistently within Electron.

handler : Event -> unit

this.offClosed handler

Full Usage: this.offClosed handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is closed. After you have received this event you should remove the reference to the window and avoid using it any more.

handler : unit -> unit

this.offEnterFullScreen handler

Full Usage: this.offEnterFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window enters a full-screen state.

handler : unit -> unit

this.offEnterHtmlFullScreen handler

Full Usage: this.offEnterHtmlFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window enters a full-screen state triggered by HTML API.

handler : unit -> unit

this.offFocus handler

Full Usage: this.offFocus handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window gains focus.

handler : unit -> unit

this.offHide handler

Full Usage: this.offHide handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is hidden.

handler : unit -> unit

this.offLeaveFullScreen handler

Full Usage: this.offLeaveFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window leaves a full-screen state.

handler : unit -> unit

this.offLeaveHtmlFullScreen handler

Full Usage: this.offLeaveHtmlFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window leaves a full-screen state triggered by HTML API.

handler : unit -> unit

this.offMaximize handler

Full Usage: this.offMaximize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when window is maximized.

handler : unit -> unit

this.offMinimize handler

Full Usage: this.offMinimize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is minimized.

handler : unit -> unit

this.offMove handler

Full Usage: this.offMove handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is being moved to a new position.

handler : unit -> unit

this.offMoved handler

Full Usage: this.offMoved handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted once when the window is moved to a new position.> [!NOTE] On macOS, this event is an alias of move.

handler : unit -> unit

this.offNewWindowForTab handler

Full Usage: this.offNewWindowForTab handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the native new tab button is clicked.

handler : unit -> unit

this.offPageTitleUpdated handler

Full Usage: this.offPageTitleUpdated handler

Parameters:
Modifiers: inline

Emitted when the document changed its title, calling event.preventDefault() will prevent the native window's title from changing. explicitSet is false when title is synthesized from file URL.

handler : IOnPageTitleUpdated -> unit

this.offPageTitleUpdated handler

Full Usage: this.offPageTitleUpdated handler

Parameters:
    handler : Event -> string -> bool -> unit

Modifiers: inline

Emitted when the document changed its title, calling event.preventDefault() will prevent the native window's title from changing. explicitSet is false when title is synthesized from file URL.

handler : Event -> string -> bool -> unit

this.offQuerySessionEnd handler

Full Usage: this.offQuerySessionEnd handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Emitted when a session is about to end due to a shutdown, machine restart, or user log-off. Calling event.preventDefault() can delay the system shutdown, though it’s generally best to respect the user’s choice to end the session. However, you may choose to use it if ending the session puts the user at risk of losing data.

handler : WindowSessionEndEvent -> unit

this.offReadyToShow handler

Full Usage: this.offReadyToShow handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the web page has been rendered (while not being shown) and window can be displayed without a visual flash.Please note that using this event implies that the renderer will be considered "visible" and paint even though show is false. This event will never fire if you use paintWhenInitiallyHidden: false

handler : unit -> unit

this.offResize handler

Full Usage: this.offResize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted after the window has been resized.

handler : unit -> unit

this.offResized handler

Full Usage: this.offResized handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted once when the window has finished being resized.This is usually emitted when the window has been resized manually. On macOS, resizing the window with setBounds/setSize and setting the animate parameter to true will also emit this event once resizing has finished.

handler : unit -> unit

this.offResponsive handler

Full Usage: this.offResponsive handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the unresponsive web page becomes responsive again.

handler : unit -> unit

this.offRestore handler

Full Usage: this.offRestore handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is restored from a minimized state.

handler : unit -> unit

this.offRotateGesture handler

Full Usage: this.offRotateGesture handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on trackpad rotation gesture. Continually emitted until rotation gesture is ended. The rotation value on each emission is the angle in degrees rotated since the last emission. The last emitted event upon a rotation gesture will always be of value 0. Counter-clockwise rotation values are positive, while clockwise ones are negative.

handler : IOnRotateGesture -> unit

this.offRotateGesture handler

Full Usage: this.offRotateGesture handler

Parameters:
    handler : Event -> float -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on trackpad rotation gesture. Continually emitted until rotation gesture is ended. The rotation value on each emission is the angle in degrees rotated since the last emission. The last emitted event upon a rotation gesture will always be of value 0. Counter-clockwise rotation values are positive, while clockwise ones are negative.

handler : Event -> float -> unit

this.offSessionEnd handler

Full Usage: this.offSessionEnd handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Emitted when a session is about to end due to a shutdown, machine restart, or user log-off. Once this event fires, there is no way to prevent the session from ending.

handler : WindowSessionEndEvent -> unit

this.offSheetBegin handler

Full Usage: this.offSheetBegin handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the window opens a sheet.

handler : unit -> unit

this.offSheetEnd handler

Full Usage: this.offSheetEnd handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the window has closed a sheet.

handler : unit -> unit

this.offShow handler

Full Usage: this.offShow handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is shown.

handler : unit -> unit

this.offSwipe handler

Full Usage: this.offSwipe handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on 3-finger swipe. Possible directions are up, right, down, left.The method underlying this event is built to handle older macOS-style trackpad swiping, where the content on the screen doesn't move with the swipe. Most macOS trackpads are not configured to allow this kind of swiping anymore, so in order for it to emit properly the 'Swipe between pages' preference in System Preferences > Trackpad > More Gestures must be set to 'Swipe with two or three fingers'.

handler : IOnSwipe -> unit

this.offSwipe handler

Full Usage: this.offSwipe handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on 3-finger swipe. Possible directions are up, right, down, left.The method underlying this event is built to handle older macOS-style trackpad swiping, where the content on the screen doesn't move with the swipe. Most macOS trackpads are not configured to allow this kind of swiping anymore, so in order for it to emit properly the 'Swipe between pages' preference in System Preferences > Trackpad > More Gestures must be set to 'Swipe with two or three fingers'.

handler : Event -> string -> unit

this.offSystemContextMenu handler

Full Usage: this.offSystemContextMenu handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when the system context menu is triggered on the window, this is normally only triggered when the user right clicks on the non-client area of your window. This is the window titlebar or any area you have declared as -webkit-app-region: drag in a frameless window.Calling event.preventDefault() will prevent the menu from being displayed.To convert point to DIP, use screen.screenToDipPoint(point).

handler : IOnSystemContextMenu -> unit

this.offSystemContextMenu handler

Full Usage: this.offSystemContextMenu handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when the system context menu is triggered on the window, this is normally only triggered when the user right clicks on the non-client area of your window. This is the window titlebar or any area you have declared as -webkit-app-region: drag in a frameless window.Calling event.preventDefault() will prevent the menu from being displayed.To convert point to DIP, use screen.screenToDipPoint(point).

handler : Event -> Point -> unit

this.offUnmaximize handler

Full Usage: this.offUnmaximize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window exits from a maximized state.

handler : unit -> unit

this.offUnresponsive handler

Full Usage: this.offUnresponsive handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the web page becomes unresponsive.

handler : unit -> unit

this.offWillMove handler

Full Usage: this.offWillMove handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is moved. On Windows, calling event.preventDefault() will prevent the window from being moved.Note that this is only emitted when the window is being moved manually. Moving the window with setPosition/setBounds/center will not emit this event.

handler : IOnWillMove -> unit

this.offWillMove handler

Full Usage: this.offWillMove handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is moved. On Windows, calling event.preventDefault() will prevent the window from being moved.Note that this is only emitted when the window is being moved manually. Moving the window with setPosition/setBounds/center will not emit this event.

handler : Event -> Rectangle -> unit

this.offWillResize handler

Full Usage: this.offWillResize handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is resized. Calling event.preventDefault() will prevent the window from being resized.Note that this is only emitted when the window is being resized manually. Resizing the window with setBounds/setSize will not emit this event.The possible values and behaviors of the edge option are platform dependent. Possible values are:* On Windows, possible values are bottom, top, left, right, top-left, top-right, bottom-left, bottom-right.* On macOS, possible values are bottom and right. * The value bottom is used to denote vertical resizing. * The value right is used to denote horizontal resizing.

handler : IOnWillResize -> unit

this.offWillResize handler

Full Usage: this.offWillResize handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is resized. Calling event.preventDefault() will prevent the window from being resized.Note that this is only emitted when the window is being resized manually. Resizing the window with setBounds/setSize will not emit this event.The possible values and behaviors of the edge option are platform dependent. Possible values are:* On Windows, possible values are bottom, top, left, right, top-left, top-right, bottom-left, bottom-right.* On macOS, possible values are bottom and right. * The value bottom is used to denote vertical resizing. * The value right is used to denote horizontal resizing.

handler : Event -> Rectangle -> Details -> unit

this.onAlwaysOnTopChanged handler

Full Usage: this.onAlwaysOnTopChanged handler

Parameters:
Modifiers: inline

Emitted when the window is set or unset to show always on top of other windows.

handler : IOnAlwaysOnTopChanged -> unit

this.onAlwaysOnTopChanged handler

Full Usage: this.onAlwaysOnTopChanged handler

Parameters:
    handler : Event -> bool -> unit

Modifiers: inline

Emitted when the window is set or unset to show always on top of other windows.

handler : Event -> bool -> unit

this.onAppCommand handler

Full Usage: this.onAppCommand handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when an App Command is invoked. These are typically related to keyboard media keys or browser commands, as well as the "Back" button built into some mice on Windows.Commands are lowercased, underscores are replaced with hyphens, and the APPCOMMAND_ prefix is stripped off. e.g. APPCOMMAND_BROWSER_BACKWARD is emitted as browser-backward.The following app commands are explicitly supported on Linux:* browser-backward* browser-forward

handler : IOnAppCommand -> unit

this.onAppCommand handler

Full Usage: this.onAppCommand handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when an App Command is invoked. These are typically related to keyboard media keys or browser commands, as well as the "Back" button built into some mice on Windows.Commands are lowercased, underscores are replaced with hyphens, and the APPCOMMAND_ prefix is stripped off. e.g. APPCOMMAND_BROWSER_BACKWARD is emitted as browser-backward.The following app commands are explicitly supported on Linux:* browser-backward* browser-forward

handler : Event -> string -> unit

this.onBlur handler

Full Usage: this.onBlur handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window loses focus.

handler : unit -> unit

this.onClose handler

Full Usage: this.onClose handler

Parameters:
    handler : Event -> unit

Modifiers: inline

Emitted when the window is going to be closed. It's emitted before the beforeunload and unload event of the DOM. Calling event.preventDefault() will cancel the close.Usually you would want to use the beforeunload handler to decide whether the window should be closed, which will also be called when the window is reloaded. In Electron, returning any value other than undefined would cancel the close. For example:> [!NOTE] There is a subtle difference between the behaviors of window.onbeforeunload = handler and window.addEventListener('beforeunload', handler). It is recommended to always set the event.returnValue explicitly, instead of only returning a value, as the former works more consistently within Electron.

handler : Event -> unit

this.onClosed handler

Full Usage: this.onClosed handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is closed. After you have received this event you should remove the reference to the window and avoid using it any more.

handler : unit -> unit

this.onEnterFullScreen handler

Full Usage: this.onEnterFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window enters a full-screen state.

handler : unit -> unit

this.onEnterHtmlFullScreen handler

Full Usage: this.onEnterHtmlFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window enters a full-screen state triggered by HTML API.

handler : unit -> unit

this.onFocus handler

Full Usage: this.onFocus handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window gains focus.

handler : unit -> unit

this.onHide handler

Full Usage: this.onHide handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is hidden.

handler : unit -> unit

this.onLeaveFullScreen handler

Full Usage: this.onLeaveFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window leaves a full-screen state.

handler : unit -> unit

this.onLeaveHtmlFullScreen handler

Full Usage: this.onLeaveHtmlFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window leaves a full-screen state triggered by HTML API.

handler : unit -> unit

this.onMaximize handler

Full Usage: this.onMaximize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when window is maximized.

handler : unit -> unit

this.onMinimize handler

Full Usage: this.onMinimize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is minimized.

handler : unit -> unit

this.onMove handler

Full Usage: this.onMove handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is being moved to a new position.

handler : unit -> unit

this.onMoved handler

Full Usage: this.onMoved handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted once when the window is moved to a new position.> [!NOTE] On macOS, this event is an alias of move.

handler : unit -> unit

this.onNewWindowForTab handler

Full Usage: this.onNewWindowForTab handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the native new tab button is clicked.

handler : unit -> unit

this.onPageTitleUpdated handler

Full Usage: this.onPageTitleUpdated handler

Parameters:
Modifiers: inline

Emitted when the document changed its title, calling event.preventDefault() will prevent the native window's title from changing. explicitSet is false when title is synthesized from file URL.

handler : IOnPageTitleUpdated -> unit

this.onPageTitleUpdated handler

Full Usage: this.onPageTitleUpdated handler

Parameters:
    handler : Event -> string -> bool -> unit

Modifiers: inline

Emitted when the document changed its title, calling event.preventDefault() will prevent the native window's title from changing. explicitSet is false when title is synthesized from file URL.

handler : Event -> string -> bool -> unit

this.onQuerySessionEnd handler

Full Usage: this.onQuerySessionEnd handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Emitted when a session is about to end due to a shutdown, machine restart, or user log-off. Calling event.preventDefault() can delay the system shutdown, though it’s generally best to respect the user’s choice to end the session. However, you may choose to use it if ending the session puts the user at risk of losing data.

handler : WindowSessionEndEvent -> unit

this.onReadyToShow handler

Full Usage: this.onReadyToShow handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the web page has been rendered (while not being shown) and window can be displayed without a visual flash.Please note that using this event implies that the renderer will be considered "visible" and paint even though show is false. This event will never fire if you use paintWhenInitiallyHidden: false

handler : unit -> unit

this.onResize handler

Full Usage: this.onResize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted after the window has been resized.

handler : unit -> unit

this.onResized handler

Full Usage: this.onResized handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted once when the window has finished being resized.This is usually emitted when the window has been resized manually. On macOS, resizing the window with setBounds/setSize and setting the animate parameter to true will also emit this event once resizing has finished.

handler : unit -> unit

this.onResponsive handler

Full Usage: this.onResponsive handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the unresponsive web page becomes responsive again.

handler : unit -> unit

this.onRestore handler

Full Usage: this.onRestore handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is restored from a minimized state.

handler : unit -> unit

this.onRotateGesture handler

Full Usage: this.onRotateGesture handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on trackpad rotation gesture. Continually emitted until rotation gesture is ended. The rotation value on each emission is the angle in degrees rotated since the last emission. The last emitted event upon a rotation gesture will always be of value 0. Counter-clockwise rotation values are positive, while clockwise ones are negative.

handler : IOnRotateGesture -> unit

this.onRotateGesture handler

Full Usage: this.onRotateGesture handler

Parameters:
    handler : Event -> float -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on trackpad rotation gesture. Continually emitted until rotation gesture is ended. The rotation value on each emission is the angle in degrees rotated since the last emission. The last emitted event upon a rotation gesture will always be of value 0. Counter-clockwise rotation values are positive, while clockwise ones are negative.

handler : Event -> float -> unit

this.onSessionEnd handler

Full Usage: this.onSessionEnd handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Emitted when a session is about to end due to a shutdown, machine restart, or user log-off. Once this event fires, there is no way to prevent the session from ending.

handler : WindowSessionEndEvent -> unit

this.onSheetBegin handler

Full Usage: this.onSheetBegin handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the window opens a sheet.

handler : unit -> unit

this.onSheetEnd handler

Full Usage: this.onSheetEnd handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the window has closed a sheet.

handler : unit -> unit

this.onShow handler

Full Usage: this.onShow handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is shown.

handler : unit -> unit

this.onSwipe handler

Full Usage: this.onSwipe handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on 3-finger swipe. Possible directions are up, right, down, left.The method underlying this event is built to handle older macOS-style trackpad swiping, where the content on the screen doesn't move with the swipe. Most macOS trackpads are not configured to allow this kind of swiping anymore, so in order for it to emit properly the 'Swipe between pages' preference in System Preferences > Trackpad > More Gestures must be set to 'Swipe with two or three fingers'.

handler : IOnSwipe -> unit

this.onSwipe handler

Full Usage: this.onSwipe handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on 3-finger swipe. Possible directions are up, right, down, left.The method underlying this event is built to handle older macOS-style trackpad swiping, where the content on the screen doesn't move with the swipe. Most macOS trackpads are not configured to allow this kind of swiping anymore, so in order for it to emit properly the 'Swipe between pages' preference in System Preferences > Trackpad > More Gestures must be set to 'Swipe with two or three fingers'.

handler : Event -> string -> unit

this.onSystemContextMenu handler

Full Usage: this.onSystemContextMenu handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when the system context menu is triggered on the window, this is normally only triggered when the user right clicks on the non-client area of your window. This is the window titlebar or any area you have declared as -webkit-app-region: drag in a frameless window.Calling event.preventDefault() will prevent the menu from being displayed.To convert point to DIP, use screen.screenToDipPoint(point).

handler : IOnSystemContextMenu -> unit

this.onSystemContextMenu handler

Full Usage: this.onSystemContextMenu handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when the system context menu is triggered on the window, this is normally only triggered when the user right clicks on the non-client area of your window. This is the window titlebar or any area you have declared as -webkit-app-region: drag in a frameless window.Calling event.preventDefault() will prevent the menu from being displayed.To convert point to DIP, use screen.screenToDipPoint(point).

handler : Event -> Point -> unit

this.onUnmaximize handler

Full Usage: this.onUnmaximize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window exits from a maximized state.

handler : unit -> unit

this.onUnresponsive handler

Full Usage: this.onUnresponsive handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the web page becomes unresponsive.

handler : unit -> unit

this.onWillMove handler

Full Usage: this.onWillMove handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is moved. On Windows, calling event.preventDefault() will prevent the window from being moved.Note that this is only emitted when the window is being moved manually. Moving the window with setPosition/setBounds/center will not emit this event.

handler : IOnWillMove -> unit

this.onWillMove handler

Full Usage: this.onWillMove handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is moved. On Windows, calling event.preventDefault() will prevent the window from being moved.Note that this is only emitted when the window is being moved manually. Moving the window with setPosition/setBounds/center will not emit this event.

handler : Event -> Rectangle -> unit

this.onWillResize handler

Full Usage: this.onWillResize handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is resized. Calling event.preventDefault() will prevent the window from being resized.Note that this is only emitted when the window is being resized manually. Resizing the window with setBounds/setSize will not emit this event.The possible values and behaviors of the edge option are platform dependent. Possible values are:* On Windows, possible values are bottom, top, left, right, top-left, top-right, bottom-left, bottom-right.* On macOS, possible values are bottom and right. * The value bottom is used to denote vertical resizing. * The value right is used to denote horizontal resizing.

handler : IOnWillResize -> unit

this.onWillResize handler

Full Usage: this.onWillResize handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is resized. Calling event.preventDefault() will prevent the window from being resized.Note that this is only emitted when the window is being resized manually. Resizing the window with setBounds/setSize will not emit this event.The possible values and behaviors of the edge option are platform dependent. Possible values are:* On Windows, possible values are bottom, top, left, right, top-left, top-right, bottom-left, bottom-right.* On macOS, possible values are bottom and right. * The value bottom is used to denote vertical resizing. * The value right is used to denote horizontal resizing.

handler : Event -> Rectangle -> Details -> unit

this.onceAlwaysOnTopChanged handler

Full Usage: this.onceAlwaysOnTopChanged handler

Parameters:
Modifiers: inline

Emitted when the window is set or unset to show always on top of other windows.

handler : IOnAlwaysOnTopChanged -> unit

this.onceAlwaysOnTopChanged handler

Full Usage: this.onceAlwaysOnTopChanged handler

Parameters:
    handler : Event -> bool -> unit

Modifiers: inline

Emitted when the window is set or unset to show always on top of other windows.

handler : Event -> bool -> unit

this.onceAppCommand handler

Full Usage: this.onceAppCommand handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when an App Command is invoked. These are typically related to keyboard media keys or browser commands, as well as the "Back" button built into some mice on Windows.Commands are lowercased, underscores are replaced with hyphens, and the APPCOMMAND_ prefix is stripped off. e.g. APPCOMMAND_BROWSER_BACKWARD is emitted as browser-backward.The following app commands are explicitly supported on Linux:* browser-backward* browser-forward

handler : IOnAppCommand -> unit

this.onceAppCommand handler

Full Usage: this.onceAppCommand handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when an App Command is invoked. These are typically related to keyboard media keys or browser commands, as well as the "Back" button built into some mice on Windows.Commands are lowercased, underscores are replaced with hyphens, and the APPCOMMAND_ prefix is stripped off. e.g. APPCOMMAND_BROWSER_BACKWARD is emitted as browser-backward.The following app commands are explicitly supported on Linux:* browser-backward* browser-forward

handler : Event -> string -> unit

this.onceBlur handler

Full Usage: this.onceBlur handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window loses focus.

handler : unit -> unit

this.onceClose handler

Full Usage: this.onceClose handler

Parameters:
    handler : Event -> unit

Modifiers: inline

Emitted when the window is going to be closed. It's emitted before the beforeunload and unload event of the DOM. Calling event.preventDefault() will cancel the close.Usually you would want to use the beforeunload handler to decide whether the window should be closed, which will also be called when the window is reloaded. In Electron, returning any value other than undefined would cancel the close. For example:> [!NOTE] There is a subtle difference between the behaviors of window.onbeforeunload = handler and window.addEventListener('beforeunload', handler). It is recommended to always set the event.returnValue explicitly, instead of only returning a value, as the former works more consistently within Electron.

handler : Event -> unit

this.onceClosed handler

Full Usage: this.onceClosed handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is closed. After you have received this event you should remove the reference to the window and avoid using it any more.

handler : unit -> unit

this.onceEnterFullScreen handler

Full Usage: this.onceEnterFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window enters a full-screen state.

handler : unit -> unit

this.onceEnterHtmlFullScreen handler

Full Usage: this.onceEnterHtmlFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window enters a full-screen state triggered by HTML API.

handler : unit -> unit

this.onceFocus handler

Full Usage: this.onceFocus handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window gains focus.

handler : unit -> unit

this.onceHide handler

Full Usage: this.onceHide handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is hidden.

handler : unit -> unit

this.onceLeaveFullScreen handler

Full Usage: this.onceLeaveFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window leaves a full-screen state.

handler : unit -> unit

this.onceLeaveHtmlFullScreen handler

Full Usage: this.onceLeaveHtmlFullScreen handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window leaves a full-screen state triggered by HTML API.

handler : unit -> unit

this.onceMaximize handler

Full Usage: this.onceMaximize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when window is maximized.

handler : unit -> unit

this.onceMinimize handler

Full Usage: this.onceMinimize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is minimized.

handler : unit -> unit

this.onceMove handler

Full Usage: this.onceMove handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is being moved to a new position.

handler : unit -> unit

this.onceMoved handler

Full Usage: this.onceMoved handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted once when the window is moved to a new position.> [!NOTE] On macOS, this event is an alias of move.

handler : unit -> unit

this.onceNewWindowForTab handler

Full Usage: this.onceNewWindowForTab handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the native new tab button is clicked.

handler : unit -> unit

this.oncePageTitleUpdated handler

Full Usage: this.oncePageTitleUpdated handler

Parameters:
Modifiers: inline

Emitted when the document changed its title, calling event.preventDefault() will prevent the native window's title from changing. explicitSet is false when title is synthesized from file URL.

handler : IOnPageTitleUpdated -> unit

this.oncePageTitleUpdated handler

Full Usage: this.oncePageTitleUpdated handler

Parameters:
    handler : Event -> string -> bool -> unit

Modifiers: inline

Emitted when the document changed its title, calling event.preventDefault() will prevent the native window's title from changing. explicitSet is false when title is synthesized from file URL.

handler : Event -> string -> bool -> unit

this.onceQuerySessionEnd handler

Full Usage: this.onceQuerySessionEnd handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Emitted when a session is about to end due to a shutdown, machine restart, or user log-off. Calling event.preventDefault() can delay the system shutdown, though it’s generally best to respect the user’s choice to end the session. However, you may choose to use it if ending the session puts the user at risk of losing data.

handler : WindowSessionEndEvent -> unit

this.onceReadyToShow handler

Full Usage: this.onceReadyToShow handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the web page has been rendered (while not being shown) and window can be displayed without a visual flash.Please note that using this event implies that the renderer will be considered "visible" and paint even though show is false. This event will never fire if you use paintWhenInitiallyHidden: false

handler : unit -> unit

this.onceResize handler

Full Usage: this.onceResize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted after the window has been resized.

handler : unit -> unit

this.onceResized handler

Full Usage: this.onceResized handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted once when the window has finished being resized.This is usually emitted when the window has been resized manually. On macOS, resizing the window with setBounds/setSize and setting the animate parameter to true will also emit this event once resizing has finished.

handler : unit -> unit

this.onceResponsive handler

Full Usage: this.onceResponsive handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the unresponsive web page becomes responsive again.

handler : unit -> unit

this.onceRestore handler

Full Usage: this.onceRestore handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is restored from a minimized state.

handler : unit -> unit

this.onceRotateGesture handler

Full Usage: this.onceRotateGesture handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on trackpad rotation gesture. Continually emitted until rotation gesture is ended. The rotation value on each emission is the angle in degrees rotated since the last emission. The last emitted event upon a rotation gesture will always be of value 0. Counter-clockwise rotation values are positive, while clockwise ones are negative.

handler : IOnRotateGesture -> unit

this.onceRotateGesture handler

Full Usage: this.onceRotateGesture handler

Parameters:
    handler : Event -> float -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on trackpad rotation gesture. Continually emitted until rotation gesture is ended. The rotation value on each emission is the angle in degrees rotated since the last emission. The last emitted event upon a rotation gesture will always be of value 0. Counter-clockwise rotation values are positive, while clockwise ones are negative.

handler : Event -> float -> unit

this.onceSessionEnd handler

Full Usage: this.onceSessionEnd handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Emitted when a session is about to end due to a shutdown, machine restart, or user log-off. Once this event fires, there is no way to prevent the session from ending.

handler : WindowSessionEndEvent -> unit

this.onceSheetBegin handler

Full Usage: this.onceSheetBegin handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the window opens a sheet.

handler : unit -> unit

this.onceSheetEnd handler

Full Usage: this.onceSheetEnd handler

Parameters:
    handler : unit -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted when the window has closed a sheet.

handler : unit -> unit

this.onceShow handler

Full Usage: this.onceShow handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window is shown.

handler : unit -> unit

this.onceSwipe handler

Full Usage: this.onceSwipe handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on 3-finger swipe. Possible directions are up, right, down, left.The method underlying this event is built to handle older macOS-style trackpad swiping, where the content on the screen doesn't move with the swipe. Most macOS trackpads are not configured to allow this kind of swiping anymore, so in order for it to emit properly the 'Swipe between pages' preference in System Preferences > Trackpad > More Gestures must be set to 'Swipe with two or three fingers'.

handler : IOnSwipe -> unit

this.onceSwipe handler

Full Usage: this.onceSwipe handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Emitted on 3-finger swipe. Possible directions are up, right, down, left.The method underlying this event is built to handle older macOS-style trackpad swiping, where the content on the screen doesn't move with the swipe. Most macOS trackpads are not configured to allow this kind of swiping anymore, so in order for it to emit properly the 'Swipe between pages' preference in System Preferences > Trackpad > More Gestures must be set to 'Swipe with two or three fingers'.

handler : Event -> string -> unit

this.onceSystemContextMenu handler

Full Usage: this.onceSystemContextMenu handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when the system context menu is triggered on the window, this is normally only triggered when the user right clicks on the non-client area of your window. This is the window titlebar or any area you have declared as -webkit-app-region: drag in a frameless window.Calling event.preventDefault() will prevent the menu from being displayed.To convert point to DIP, use screen.screenToDipPoint(point).

handler : IOnSystemContextMenu -> unit

this.onceSystemContextMenu handler

Full Usage: this.onceSystemContextMenu handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Emitted when the system context menu is triggered on the window, this is normally only triggered when the user right clicks on the non-client area of your window. This is the window titlebar or any area you have declared as -webkit-app-region: drag in a frameless window.Calling event.preventDefault() will prevent the menu from being displayed.To convert point to DIP, use screen.screenToDipPoint(point).

handler : Event -> Point -> unit

this.onceUnmaximize handler

Full Usage: this.onceUnmaximize handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the window exits from a maximized state.

handler : unit -> unit

this.onceUnresponsive handler

Full Usage: this.onceUnresponsive handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the web page becomes unresponsive.

handler : unit -> unit

this.onceWillMove handler

Full Usage: this.onceWillMove handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is moved. On Windows, calling event.preventDefault() will prevent the window from being moved.Note that this is only emitted when the window is being moved manually. Moving the window with setPosition/setBounds/center will not emit this event.

handler : IOnWillMove -> unit

this.onceWillMove handler

Full Usage: this.onceWillMove handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is moved. On Windows, calling event.preventDefault() will prevent the window from being moved.Note that this is only emitted when the window is being moved manually. Moving the window with setPosition/setBounds/center will not emit this event.

handler : Event -> Rectangle -> unit

this.onceWillResize handler

Full Usage: this.onceWillResize handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is resized. Calling event.preventDefault() will prevent the window from being resized.Note that this is only emitted when the window is being resized manually. Resizing the window with setBounds/setSize will not emit this event.The possible values and behaviors of the edge option are platform dependent. Possible values are:* On Windows, possible values are bottom, top, left, right, top-left, top-right, bottom-left, bottom-right.* On macOS, possible values are bottom and right. * The value bottom is used to denote vertical resizing. * The value right is used to denote horizontal resizing.

handler : IOnWillResize -> unit

this.onceWillResize handler

Full Usage: this.onceWillResize handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Emitted before the window is resized. Calling event.preventDefault() will prevent the window from being resized.Note that this is only emitted when the window is being resized manually. Resizing the window with setBounds/setSize will not emit this event.The possible values and behaviors of the edge option are platform dependent. Possible values are:* On Windows, possible values are bottom, top, left, right, top-left, top-right, bottom-left, bottom-right.* On macOS, possible values are bottom and right. * The value bottom is used to denote vertical resizing. * The value right is used to denote horizontal resizing.

handler : Event -> Rectangle -> Details -> unit

this.previewFile (path, ?displayName)

Full Usage: this.previewFile (path, ?displayName)

Parameters:
    path : string
    ?displayName : string

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

path : string
?displayName : string

this.reload ()

Full Usage: this.reload ()

Modifiers: inline

Same as webContents.reload.

this.removeMenu ()

Full Usage: this.removeMenu ()

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Remove the window's menu bar.

this.representedFilename

Full Usage: this.representedFilename

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ 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.

this.resizable

Full Usage: this.resizable

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

this.restore ()

Full Usage: this.restore ()

Modifiers: inline

Restores the window from minimized state to its previous state.

this.selectNextTab ()

Full Usage: this.selectNextTab ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

this.selectPreviousTab ()

Full Usage: this.selectPreviousTab ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

this.setAccentColor accentColor

Full Usage: this.setAccentColor accentColor

Parameters:
    accentColor : U2<bool, string>

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Sets the system accent color and highlighting of active window border.The accentColor parameter accepts the following values:* Color string - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.* true - Uses the system's default accent color from user preferences in System Settings.* false - Explicitly disables accent color highlighting for the window.Examples:

accentColor : U2<bool, string>

this.setAlwaysOnTop (flag, ?level, ?relativeLevel)

Full Usage: this.setAlwaysOnTop (flag, ?level, ?relativeLevel)

Parameters:
    flag : bool
    ?level : Level
    ?relativeLevel : int

Modifiers: inline

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.

flag : bool
?level : Level
?relativeLevel : int

this.setAppDetails (?appId, ?appIconPath, ?appIconIndex, ?relaunchCommand, ?relaunchDisplayName)

Full Usage: this.setAppDetails (?appId, ?appIconPath, ?appIconIndex, ?relaunchCommand, ?relaunchDisplayName)

Parameters:
    ?appId : string
    ?appIconPath : string
    ?appIconIndex : int
    ?relaunchCommand : string
    ?relaunchDisplayName : string

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Sets the properties for the window's taskbar button.> [!NOTE] relaunchCommand and relaunchDisplayName must always be set together. If one of those properties is not set, then neither will be used.

?appId : string
?appIconPath : string
?appIconIndex : int
?relaunchCommand : string
?relaunchDisplayName : string

this.setAspectRatio (aspectRatio, ?extraSize)

Full Usage: this.setAspectRatio (aspectRatio, ?extraSize)

Parameters:
    aspectRatio : float
    ?extraSize : Size

Modifiers: inline

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.Consider a normal window with an HD video player and associated controls. Perhaps there are 15 pixels of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within the player itself we would call this function with arguments of 16/9 and { width: 40, height: 50 }. The second argument doesn't care where the extra width and height are within the content view--only that they exist. Sum any extra width and height areas you have within the overall content view.The aspect ratio is not respected when window is resized programmatically with APIs like win.setSize.To reset an aspect ratio, pass 0 as the aspectRatio value: win.setAspectRatio(0).

aspectRatio : float
?extraSize : Size

this.setAutoHideCursor autoHide

Full Usage: this.setAutoHideCursor autoHide

Parameters:
    autoHide : bool

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Controls whether to hide cursor when typing.

autoHide : bool

this.setAutoHideMenuBar hide

Full Usage: this.setAutoHideMenuBar hide

Parameters:
    hide : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

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.If the menu bar is already visible, calling setAutoHideMenuBar(true) won't hide it immediately.

hide : bool

this.setBackgroundColor backgroundColor

Full Usage: this.setBackgroundColor backgroundColor

Parameters:
    backgroundColor : string

Modifiers: inline

Examples of valid backgroundColor values:* Hex * #fff (shorthand RGB) * #ffff (shorthand ARGB) * #ffffff (RGB) * #ffffffff (ARGB)* RGB * rgb(([\d]+),\s*([\d]+),\s*([\d]+)) * e.g. rgb(255, 255, 255)* RGBA * rgba(([\d]+),\s*([\d]+),\s*([\d]+),\s*([\d.]+)) * e.g. rgba(255, 255, 255, 1.0)* HSL * hsl((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%) * e.g. hsl(200, 20%, 50%)* HSLA * hsla((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)) * e.g. hsla(200, 20%, 50%, 0.5)* Color name * Options are listed in SkParseColor.cpp * Similar to CSS Color Module Level 3 keywords, but case-sensitive. * e.g. blueviolet or redSets the background color of the window. See Setting backgroundColor.

backgroundColor : string

this.setBackgroundMaterial material

Full Usage: this.setBackgroundMaterial material

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

This method sets the browser window's system-drawn background material, including behind the non-client area.See the Windows documentation for more details.> [!NOTE] This method is only supported on Windows 11 22H2 and up.

material : Material

this.setBounds (bounds, ?animate)

Full Usage: this.setBounds (bounds, ?animate)

Parameters:
Modifiers: inline

Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.On Wayland (Linux), has the same limitations as setSize and setPosition.> [!NOTE] On macOS, the y-coordinate value cannot be smaller than the Tray height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.

bounds : Rectangle
?animate : bool

this.setClosable closable

Full Usage: this.setClosable closable

Parameters:
    closable : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

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

closable : bool

this.setContentBounds (bounds, ?animate)

Full Usage: this.setContentBounds (bounds, ?animate)

Parameters:
Modifiers: inline

Resizes and moves the window's client area (e.g. the web page) to the supplied bounds.On Wayland (Linux), has the same limitations as setContentSize and setPosition.

bounds : Rectangle
?animate : bool

this.setContentProtection enable

Full Usage: this.setContentProtection enable

Parameters:
    enable : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Prevents the window contents from being captured by other apps.On Windows, it calls SetWindowDisplayAffinity with WDA_EXCLUDEFROMCAPTURE. For Windows 10 version 2004 and up the window will be removed from capture entirely, older Windows versions behave as if WDA_MONITOR is applied capturing a black window.On macOS, it sets the NSWindow's sharingType to NSWindowSharingNone. Unfortunately, due to an intentional change in macOS, newer Mac applications that use ScreenCaptureKit will capture your window despite win.setContentProtection(true). See here.

enable : bool

this.setContentSize (width, height, ?animate)

Full Usage: this.setContentSize (width, height, ?animate)

Parameters:
    width : int
    height : int
    ?animate : bool

Modifiers: inline

Resizes the window's client area (e.g. the web page) to width and height.On Wayland (Linux), may not work as some window managers restrict programmatic window resizing.

width : int
height : int
?animate : bool

this.setContentView view

Full Usage: this.setContentView view

Parameters:
Modifiers: inline

Sets the content view of the window.

view : View

this.setDocumentEdited edited

Full Usage: this.setDocumentEdited edited

Parameters:
    edited : bool

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

edited : bool

this.setEnabled enable

Full Usage: this.setEnabled enable

Parameters:
    enable : bool

Modifiers: inline

Disable or enable the window.

enable : bool

this.setFocusable focusable

Full Usage: this.setFocusable focusable

Parameters:
    focusable : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Changes whether the window can be focused.On macOS it does not remove the focus from the window.

focusable : bool

this.setFullScreen flag

Full Usage: this.setFullScreen flag

Parameters:
    flag : bool

Modifiers: inline

Sets whether the window should be in fullscreen mode.> [!NOTE] On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the 'enter-full-screen' or 'leave-full-screen' events.

flag : bool

this.setFullScreenable fullscreenable

Full Usage: this.setFullScreenable fullscreenable

Parameters:
    fullscreenable : bool

Modifiers: inline

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

fullscreenable : bool

this.setHasShadow hasShadow

Full Usage: this.setHasShadow hasShadow

Parameters:
    hasShadow : bool

Modifiers: inline

Sets whether the window should have a shadow.

hasShadow : bool

this.setHiddenInMissionControl hidden

Full Usage: this.setHiddenInMissionControl hidden

Parameters:
    hidden : bool

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

hidden : bool

this.setIcon icon

Full Usage: this.setIcon icon

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Changes window icon.

icon : U2<NativeImage, string>

this.setIgnoreMouseEvents (ignore, ?forward)

Full Usage: this.setIgnoreMouseEvents (ignore, ?forward)

Parameters:
    ignore : bool
    ?forward : bool

Modifiers: inline

Makes the window ignore all mouse events.All mouse events happened in this window will be passed to the window below this window, but if this window has focus, it will still receive keyboard events.

ignore : bool
?forward : bool

this.setKiosk flag

Full Usage: this.setKiosk flag

Parameters:
    flag : bool

Modifiers: inline

Enters or leaves kiosk mode.

flag : bool

this.setMaximizable maximizable

Full Usage: this.setMaximizable maximizable

Parameters:
    maximizable : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

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

maximizable : bool

this.setMaximumSize (width, height)

Full Usage: this.setMaximumSize (width, height)

Parameters:
    width : int
    height : int

Modifiers: inline

Sets the maximum size of window to width and height.

width : int
height : int

this.setMenu menu

Full Usage: this.setMenu menu

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

Sets the menu as the window's menu bar.

menu : Option<Menu>

this.setMenuBarVisibility visible

Full Usage: this.setMenuBarVisibility visible

Parameters:
    visible : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

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.

visible : bool

this.setMinimizable minimizable

Full Usage: this.setMinimizable minimizable

Parameters:
    minimizable : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

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

minimizable : bool

this.setMinimumSize (width, height)

Full Usage: this.setMinimumSize (width, height)

Parameters:
    width : int
    height : int

Modifiers: inline

Sets the minimum size of window to width and height.

width : int
height : int

this.setMovable movable

Full Usage: this.setMovable movable

Parameters:
    movable : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

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

movable : bool

this.setOpacity opacity

Full Usage: this.setOpacity opacity

Parameters:
    opacity : float

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

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

opacity : float

this.setOverlayIcon (overlay, description)

Full Usage: this.setOverlayIcon (overlay, description)

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

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.

overlay : Option<NativeImage>
description : string

this.setParentWindow parent

Full Usage: this.setParentWindow parent

Parameters:
Modifiers: inline

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

parent : Option<BrowserWindow>

this.setPosition (x, y, ?animate)

Full Usage: this.setPosition (x, y, ?animate)

Parameters:
    x : int
    y : int
    ?animate : bool

Modifiers: inline

Moves window to x and y.Not supported on Wayland (Linux).

x : int
y : int
?animate : bool

this.setProgressBar (progress, ?options)

Full Usage: this.setProgressBar (progress, ?options)

Parameters:
    progress : double
    ?options : Options

Modifiers: inline

Sets progress value in progress bar. Valid range is [0, 1.0].Remove progress bar when progress < 0; Change to indeterminate mode when progress > 1.On Linux platform, only supports Unity desktop environment, you need to specify the *.desktop file name to desktopName field in package.json. By default, it will assume {app.name}.desktop.On Windows, a mode can be passed. Accepted values are none, normal, indeterminate, error, and paused. If you call setProgressBar without a mode set (but with a value within the valid range), normal will be assumed.

progress : double
?options : Options

this.setRepresentedFilename filename

Full Usage: this.setRepresentedFilename filename

Parameters:
    filename : string

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

filename : string

this.setResizable resizable

Full Usage: this.setResizable resizable

Parameters:
    resizable : bool

Modifiers: inline

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

resizable : bool

this.setShape rects

Full Usage: this.setShape rects

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

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.

rects : Rectangle[]

this.setSheetOffset (offsetY, ?offsetX)

Full Usage: this.setSheetOffset (offsetY, ?offsetX)

Parameters:
    offsetY : float
    ?offsetX : float

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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:

offsetY : float
?offsetX : float

this.setSimpleFullScreen flag

Full Usage: this.setSimpleFullScreen flag

Parameters:
    flag : bool

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Enters or leaves simple fullscreen mode.Simple fullscreen mode emulates the native fullscreen behavior found in versions of macOS prior to Lion (10.7).

flag : bool

this.setSize (width, height, ?animate)

Full Usage: this.setSize (width, height, ?animate)

Parameters:
    width : int
    height : int
    ?animate : bool

Modifiers: inline

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.On Wayland (Linux), may not work as some window managers restrict programmatic window resizing.

width : int
height : int
?animate : bool

this.setSkipTaskbar skip

Full Usage: this.setSkipTaskbar skip

Parameters:
    skip : bool

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Makes the window not show in the taskbar.

skip : bool

this.setThumbarButtons buttons

Full Usage: this.setThumbarButtons buttons

Parameters:
Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Whether the buttons were added successfullyAdd a thumbnail toolbar with a specified set of buttons to the thumbnail image of a window in a taskbar button layout. Returns a boolean object indicates whether the thumbnail has been added successfully.The number of buttons in thumbnail toolbar should be no greater than 7 due to the limited room. Once you setup the thumbnail toolbar, the toolbar cannot be removed due to the platform's limitation. But you can call the API with an empty array to clean the buttons.The buttons is an array of Button objects:* Button Object * icon NativeImage - The icon showing in thumbnail toolbar. * click Function * tooltip string (optional) - The text of the button's tooltip. * flags string[] (optional) - Control specific states and behaviors of the button. By default, it is ['enabled'].The flags is an array that can include following strings:* enabled - The button is active and available to the user.* disabled - The button is disabled. It is present, but has a visual state indicating it will not respond to user action.* dismissonclick - When the button is clicked, the thumbnail window closes immediately.* nobackground - Do not draw a button border, use only the image.* hidden - The button is not shown to the user.* noninteractive - The button is enabled but not interactive; no pressed button state is drawn. This value is intended for instances where the button is used in a notification.

buttons : ThumbarButton[]
Returns: bool

this.setThumbnailClip region

Full Usage: this.setThumbnailClip region

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

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 }.

region : Rectangle

this.setThumbnailToolTip toolTip

Full Usage: this.setThumbnailToolTip toolTip

Parameters:
    toolTip : string

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

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

toolTip : string

this.setTitle title

Full Usage: this.setTitle title

Parameters:
    title : string

Modifiers: inline

Changes the title of native window to title.

title : string

this.setTitleBarOverlay (?color, ?symbolColor, ?height)

Full Usage: this.setTitleBarOverlay (?color, ?symbolColor, ?height)

Parameters:
    ?color : string
    ?symbolColor : string
    ?height : int

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

On a window with Window Controls Overlay already enabled, this method updates the style of the title bar overlay.On Linux, the symbolColor is automatically calculated to have minimum accessible contrast to the color if not explicitly set.

?color : string
?symbolColor : string
?height : int

this.setTouchBar touchBar

Full Usage: this.setTouchBar touchBar

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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.> [!NOTE] The TouchBar API is currently experimental and may change or be removed in future Electron releases.

touchBar : Option<TouchBar>

this.setVibrancy (type, ?animationDuration)

Full Usage: this.setVibrancy (type, ?animationDuration)

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Adds a vibrancy effect to the browser window. Passing null or an empty string will remove the vibrancy effect on the window. The animationDuration parameter only animates fading in or fading out the vibrancy effect. Animating between different types of vibrancy is not supported.

type : Option<Type>
?animationDuration : float

this.setVisibleOnAllWorkspaces (visible, ?visibleOnFullScreen, ?skipTransformProcessType)

Full Usage: this.setVisibleOnAllWorkspaces (visible, ?visibleOnFullScreen, ?skipTransformProcessType)

Parameters:
    visible : bool
    ?visibleOnFullScreen : bool
    ?skipTransformProcessType : bool

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ✔ | MAS ❌

Sets whether the window should be visible on all workspaces.> [!NOTE] This API does nothing on Windows.

visible : bool
?visibleOnFullScreen : bool
?skipTransformProcessType : bool

this.setWindowButtonPosition position

Full Usage: this.setWindowButtonPosition position

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

position : Option<Point>

this.setWindowButtonVisibility visible

Full Usage: this.setWindowButtonVisibility visible

Parameters:
    visible : bool

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Sets whether the window traffic light buttons should be visible.

visible : bool

this.shadow

Full Usage: this.shadow

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

this.show ()

Full Usage: this.show ()

Modifiers: inline

Shows and gives focus to the window.

this.showAllTabs ()

Full Usage: this.showAllTabs ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

this.showDefinitionForSelection ()

Full Usage: this.showDefinitionForSelection ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Same as webContents.showDefinitionForSelection().

this.showInactive ()

Full Usage: this.showInactive ()

Modifiers: inline

Shows the window but doesn't focus on it.Not supported on Wayland (Linux).

this.simpleFullScreen

Full Usage: this.simpleFullScreen

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

this.snapped

Full Usage: this.snapped

Returns: bool

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌ A boolean property that indicates whether the window is arranged via Snap.

Returns: bool

this.tabbingIdentifier

Full Usage: this.tabbingIdentifier

Returns: string

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ A string (optional) property that is equal to the tabbingIdentifier passed to the BrowserWindow constructor or undefined if none was set.

Returns: string

this.title

Full Usage: this.title

A string property that determines the title of the native window.> [!NOTE] The title of the web page can be different from the title of the native window.

this.toggleTabBar ()

Full Usage: this.toggleTabBar ()

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

this.unhookAllWindowMessages ()

Full Usage: this.unhookAllWindowMessages ()

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Unhooks all of the window messages.

this.unhookWindowMessage message

Full Usage: this.unhookWindowMessage message

Parameters:
    message : int

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

Unhook the window message.

message : int

this.unmaximize ()

Full Usage: this.unmaximize ()

Modifiers: inline

Unmaximizes the window.

this.visibleOnAllWorkspaces

Full Usage: this.visibleOnAllWorkspaces

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ✔ | MAS ❌ A boolean property that determines whether the window is visible on all workspaces.> [!NOTE] Always returns false on Windows.

this.webContents

Full Usage: this.webContents

Returns: WebContents

A WebContents object this window owns. All web page related events and operations will be done via it.See the webContents documentation for its methods and events.

Returns: WebContents

Static members

Static member Description

BrowserWindow.fromId id

Full Usage: BrowserWindow.fromId id

Parameters:
    id : int

Returns: Option<BrowserWindow>
Modifiers: inline

The window with the given id.

id : int
Returns: Option<BrowserWindow>

BrowserWindow.fromWebContents webContents

Full Usage: BrowserWindow.fromWebContents webContents

Parameters:
Returns: Option<BrowserWindow>
Modifiers: inline

The window that owns the given webContents or null if the contents are not owned by a window.

webContents : WebContents
Returns: Option<BrowserWindow>

BrowserWindow.getAllWindows ()

Full Usage: BrowserWindow.getAllWindows ()

Returns: BrowserWindow[]
Modifiers: inline

An array of all opened browser windows.

Returns: BrowserWindow[]

BrowserWindow.getFocusedWindow ()

Full Usage: BrowserWindow.getFocusedWindow ()

Returns: Option<BrowserWindow>
Modifiers: inline

The window that is focused in this application, otherwise returns null.

Returns: Option<BrowserWindow>

Type something to start searching.