BaseWindow Type
⚠ Process Availability: Main ✔ | Renderer ❌ | Utility ❌ | Exported ✔
Create and control windows.Process: Main> [!NOTE] BaseWindow provides a flexible way to compose multiple web views in a single window. For windows with only a single, full-size web view, the BrowserWindow class may be a simpler option.This module cannot be used until the ready event of the app module is emitted.### Parent and child windowsBy using parent option, you can create child windows:const { BaseWindow } = require('electron')const parent = new BaseWindow()const child = new BaseWindow({ parent })The child window will always show on top of the parent 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 { BaseWindow } = require('electron')const parent = new BaseWindow()const child = new BaseWindow({ parent, modal: true })### 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.### Resource managementWhen you add a WebContentsView to a BaseWindow and the BaseWindow is closed, the webContents of the WebContentsView are not destroyed automatically.It is your responsibility to close the webContents when you no longer need them, e.g. when the BaseWindow is closed:const { BaseWindow, WebContentsView } = require('electron')const win = new BaseWindow({ width: 800, height: 600 })const view = new WebContentsView()win.contentView.addChildView(view)win.on('closed', () => { view.webContents.close()})Unlike with a BrowserWindow, if you don't explicitly close the webContents, you'll encounter memory leaks.### Class: BaseWindow> Create and control windows.Process: MainBaseWindow is an EventEmitter.It creates a new BaseWindow 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
|
Full Usage:
BaseWindow(?options)
Parameters:
BaseWindowConstructorOptions
-
Returns: BaseWindow
|
|
Instance members
| Instance member |
Description
|
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. |
|
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Adds a window as a tab on this window, after the tab for the window instance.
|
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. |
Full Usage:
this.blur ()
Modifiers: inline |
Removes focus from the window. |
Full Usage:
this.center ()
Modifiers: inline |
Moves window to the center of the screen. |
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. |
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. |
Full Usage:
this.closeFilePreview ()
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Closes the currently open Quick Look panel. |
Full Usage:
this.contentView
|
A View property for the content view of the window. |
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. |
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. |
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. |
Full Usage:
this.flashFrame flag
Parameters:
bool
Modifiers: inline |
Starts or stops flashing the window to attract user's attention.
|
Full Usage:
this.focus ()
Modifiers: inline |
Focuses on the window. |
Full Usage:
this.focusable
|
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that determines whether the window is focusable. |
Full Usage:
this.fullScreen
|
A boolean property that determines whether the window is in fullscreen mode. |
Full Usage:
this.fullScreenable
|
A boolean property that determines whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. |
|
⚠ 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.
|
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.
|
|
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 }.
|
|
All child windows.
|
|
The bounds of the window's client area as Object.
|
Full Usage:
this.getContentSize ()
Returns: int[]
Modifiers: inline |
Contains the window's client area's width and height.
|
|
The content view of the window.
|
Full Usage:
this.getMaximumSize ()
Returns: int[]
Modifiers: inline |
Contains the window's maximum width and height.
|
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.
|
Full Usage:
this.getMinimumSize ()
Returns: int[]
Modifiers: inline |
Contains the window's minimum width and height.
|
|
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.
|
|
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 returns the same Rectangle.
|
Full Usage:
this.getOpacity ()
Returns: float
Modifiers: inline |
between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns 1.
|
|
The parent window or null if there is no parent.
|
Full Usage:
this.getPosition ()
Returns: int[]
Modifiers: inline |
Contains the window's current position.
|
Full Usage:
this.getRepresentedFilename ()
Returns: string
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ The pathname of the file the window represents.
|
Full Usage:
this.getSize ()
Returns: int[]
Modifiers: inline |
Contains the window's width and height.
|
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.
|
|
|
Full Usage:
this.hasShadow ()
Returns: bool
Modifiers: inline |
Whether the window has a shadow.
|
Full Usage:
this.hide ()
Modifiers: inline |
Hides the window. |
|
|
Full Usage:
this.id
Returns: int
|
A Integer property representing the unique ID of the window. Each ID is unique among all BaseWindow instances of the entire Electron application.
|
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.BaseWindows 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. |
Full Usage:
this.isAlwaysOnTop ()
Returns: bool
Modifiers: inline |
Whether the window is always on top of other windows.
|
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.
|
Full Usage:
this.isContentProtected ()
Returns: bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ whether or not content protection is currently enabled.
|
Full Usage:
this.isDestroyed ()
Returns: bool
Modifiers: inline |
Whether the window is destroyed.
|
Full Usage:
this.isDocumentEdited ()
Returns: bool
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Whether the window's document has been edited.
|
Full Usage:
this.isEnabled ()
Returns: bool
Modifiers: inline |
whether the window is enabled.
|
Full Usage:
this.isFocusable ()
Returns: bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ Whether the window can be focused.
|
Full Usage:
this.isFocused ()
Returns: bool
Modifiers: inline |
Whether the window is focused.
|
Full Usage:
this.isFullScreen ()
Returns: bool
Modifiers: inline |
Whether the window is in fullscreen mode.
|
Full Usage:
this.isFullScreenable ()
Returns: bool
Modifiers: inline |
Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
|
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.
|
Full Usage:
this.isKiosk ()
Returns: bool
Modifiers: inline |
Whether the window is in kiosk mode.
|
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.
|
Full Usage:
this.isMaximized ()
Returns: bool
Modifiers: inline |
Whether the window is maximized.
|
Full Usage:
this.isMenuBarAutoHide ()
Returns: bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌ Whether menu bar automatically hides itself.
|
Full Usage:
this.isMenuBarVisible ()
Returns: bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌ Whether the menu bar is visible.
|
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.
|
Full Usage:
this.isMinimized ()
Returns: bool
Modifiers: inline |
Whether the window is minimized.
|
Full Usage:
this.isModal ()
Returns: bool
Modifiers: inline |
Whether current window is a modal window.
|
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.
|
Full Usage:
this.isNormal ()
Returns: bool
Modifiers: inline |
Whether the window is in normal state (not maximized, not minimized, not in fullscreen mode).
|
Full Usage:
this.isResizable ()
Returns: bool
Modifiers: inline |
Whether the window can be manually resized by the user.
|
Full Usage:
this.isSimpleFullScreen ()
Returns: bool
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Whether the window is in simple (pre-Lion) fullscreen mode.
|
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.
|
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.
|
Full Usage:
this.isVisible ()
Returns: bool
Modifiers: inline |
Whether the window is visible to the user in the foreground of the app.
|
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.
|
Full Usage:
this.isWindowMessageHooked message
Parameters:
int
Returns: bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌ true or false depending on whether the message is hooked.
|
Full Usage:
this.kiosk
|
A boolean property that determines whether the window is in kiosk mode. |
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. |
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. |
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. |
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. |
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. |
Full Usage:
this.minimize ()
Modifiers: inline |
Minimizes the window. On some platforms the minimized window will be shown in the Dock. |
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. |
Full Usage:
this.moveAbove mediaSourceId
Parameters:
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.
|
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. |
Full Usage:
this.moveTop ()
Modifiers: inline |
Moves window to top(z-order) regardless of focus |
Full Usage:
this.offAlwaysOnTopChanged handler
Parameters:
IOnAlwaysOnTopChanged -> unit
Modifiers: inline |
Emitted when the window is set or unset to show always on top of other windows.
|
Full Usage:
this.offAlwaysOnTopChanged handler
Parameters:
Event -> bool -> unit
Modifiers: inline |
Emitted when the window is set or unset to show always on top of other windows.
|
Full Usage:
this.offAppCommand handler
Parameters:
IOnAppCommand -> 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
|
Full Usage:
this.offAppCommand handler
Parameters:
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
|
|
Emitted when the window loses focus.
|
|
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.
|
Full Usage:
this.offClosed handler
Parameters:
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.
|
Full Usage:
this.offEnterFullScreen handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window enters a full-screen state.
|
|
Emitted when the window gains focus.
|
Full Usage:
this.offHide handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is hidden.
|
Full Usage:
this.offLeaveFullScreen handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window leaves a full-screen state.
|
Full Usage:
this.offMaximize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when window is maximized.
|
Full Usage:
this.offMinimize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is minimized.
|
Full Usage:
this.offMove handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is being moved to a new position.
|
Full Usage:
this.offMoved handler
Parameters:
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.
|
Full Usage:
this.offNewWindowForTab handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the native new tab button is clicked.
|
Full Usage:
this.offQuerySessionEnd handler
Parameters:
WindowSessionEndEvent -> unit
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.
|
Full Usage:
this.offResize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted after the window has been resized.
|
Full Usage:
this.offResized handler
Parameters:
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.
|
Full Usage:
this.offRestore handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is restored from a minimized state.
|
Full Usage:
this.offRotateGesture handler
Parameters:
IOnRotateGesture -> 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.
|
Full Usage:
this.offRotateGesture handler
Parameters:
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.
|
Full Usage:
this.offSessionEnd handler
Parameters:
WindowSessionEndEvent -> unit
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.
|
Full Usage:
this.offSheetBegin handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the window opens a sheet.
|
Full Usage:
this.offSheetEnd handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the window has closed a sheet.
|
Full Usage:
this.offShow handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is shown.
|
|
⚠ 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'.
|
|
⚠ 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'.
|
Full Usage:
this.offSystemContextMenu handler
Parameters:
IOnSystemContextMenu -> unit
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).
|
|
⚠ 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). |
Full Usage:
this.offUnmaximize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window exits from a maximized state.
|
|
⚠ 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.
|
|
⚠ 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. |
Full Usage:
this.offWillResize handler
Parameters:
IOnWillResize -> unit
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.
|
|
⚠ 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. |
Full Usage:
this.onAlwaysOnTopChanged handler
Parameters:
IOnAlwaysOnTopChanged -> unit
Modifiers: inline |
Emitted when the window is set or unset to show always on top of other windows.
|
Full Usage:
this.onAlwaysOnTopChanged handler
Parameters:
Event -> bool -> unit
Modifiers: inline |
Emitted when the window is set or unset to show always on top of other windows.
|
|
⚠ 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
|
Full Usage:
this.onAppCommand handler
Parameters:
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
|
|
Emitted when the window loses focus.
|
|
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.
|
Full Usage:
this.onClosed handler
Parameters:
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.
|
Full Usage:
this.onEnterFullScreen handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window enters a full-screen state.
|
|
Emitted when the window gains focus.
|
Full Usage:
this.onHide handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is hidden.
|
Full Usage:
this.onLeaveFullScreen handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window leaves a full-screen state.
|
Full Usage:
this.onMaximize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when window is maximized.
|
Full Usage:
this.onMinimize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is minimized.
|
Full Usage:
this.onMove handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is being moved to a new position.
|
Full Usage:
this.onMoved handler
Parameters:
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.
|
Full Usage:
this.onNewWindowForTab handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the native new tab button is clicked.
|
Full Usage:
this.onQuerySessionEnd handler
Parameters:
WindowSessionEndEvent -> unit
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.
|
Full Usage:
this.onResize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted after the window has been resized.
|
Full Usage:
this.onResized handler
Parameters:
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.
|
Full Usage:
this.onRestore handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is restored from a minimized state.
|
Full Usage:
this.onRotateGesture handler
Parameters:
IOnRotateGesture -> 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.
|
Full Usage:
this.onRotateGesture handler
Parameters:
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.
|
Full Usage:
this.onSessionEnd handler
Parameters:
WindowSessionEndEvent -> unit
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.
|
Full Usage:
this.onSheetBegin handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the window opens a sheet.
|
Full Usage:
this.onSheetEnd handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the window has closed a sheet.
|
Full Usage:
this.onShow handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is shown.
|
|
⚠ 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'.
|
|
⚠ 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'.
|
Full Usage:
this.onSystemContextMenu handler
Parameters:
IOnSystemContextMenu -> unit
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).
|
|
⚠ 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). |
Full Usage:
this.onUnmaximize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window exits from a maximized state.
|
|
⚠ 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.
|
|
⚠ 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. |
|
⚠ 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.
|
|
⚠ 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. |
Full Usage:
this.onceAlwaysOnTopChanged handler
Parameters:
IOnAlwaysOnTopChanged -> unit
Modifiers: inline |
Emitted when the window is set or unset to show always on top of other windows.
|
Full Usage:
this.onceAlwaysOnTopChanged handler
Parameters:
Event -> bool -> unit
Modifiers: inline |
Emitted when the window is set or unset to show always on top of other windows.
|
Full Usage:
this.onceAppCommand handler
Parameters:
IOnAppCommand -> 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
|
Full Usage:
this.onceAppCommand handler
Parameters:
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
|
|
Emitted when the window loses focus.
|
|
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.
|
Full Usage:
this.onceClosed handler
Parameters:
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.
|
Full Usage:
this.onceEnterFullScreen handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window enters a full-screen state.
|
|
Emitted when the window gains focus.
|
Full Usage:
this.onceHide handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is hidden.
|
Full Usage:
this.onceLeaveFullScreen handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window leaves a full-screen state.
|
Full Usage:
this.onceMaximize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when window is maximized.
|
Full Usage:
this.onceMinimize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is minimized.
|
Full Usage:
this.onceMove handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is being moved to a new position.
|
Full Usage:
this.onceMoved handler
Parameters:
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.
|
Full Usage:
this.onceNewWindowForTab handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the native new tab button is clicked.
|
Full Usage:
this.onceQuerySessionEnd handler
Parameters:
WindowSessionEndEvent -> unit
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.
|
Full Usage:
this.onceResize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted after the window has been resized.
|
Full Usage:
this.onceResized handler
Parameters:
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.
|
Full Usage:
this.onceRestore handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is restored from a minimized state.
|
Full Usage:
this.onceRotateGesture handler
Parameters:
IOnRotateGesture -> 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.
|
Full Usage:
this.onceRotateGesture handler
Parameters:
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.
|
Full Usage:
this.onceSessionEnd handler
Parameters:
WindowSessionEndEvent -> unit
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.
|
Full Usage:
this.onceSheetBegin handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the window opens a sheet.
|
Full Usage:
this.onceSheetEnd handler
Parameters:
unit -> unit
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Emitted when the window has closed a sheet.
|
Full Usage:
this.onceShow handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window is shown.
|
|
⚠ 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'.
|
|
⚠ 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'.
|
Full Usage:
this.onceSystemContextMenu handler
Parameters:
IOnSystemContextMenu -> unit
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).
|
|
⚠ 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). |
Full Usage:
this.onceUnmaximize handler
Parameters:
unit -> unit
Modifiers: inline |
Emitted when the window exits from a maximized state.
|
|
⚠ 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.
|
|
⚠ 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. |
Full Usage:
this.onceWillResize handler
Parameters:
IOnWillResize -> unit
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.
|
|
⚠ 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. |
Full Usage:
this.previewFile (path, ?displayName)
Parameters:
string
?displayName : string
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Uses Quick Look to preview a file at a given path.
|
Full Usage:
this.removeMenu ()
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌ Remove the window's menu bar. |
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. |
Full Usage:
this.resizable
|
A boolean property that determines whether the window can be manually resized by user. |
Full Usage:
this.restore ()
Modifiers: inline |
Restores the window from minimized state to its previous state. |
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. |
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. |
Full Usage:
this.setAccentColor accentColor
Parameters:
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:
|
Full Usage:
this.setAlwaysOnTop (flag, ?level, ?relativeLevel)
Parameters:
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.
|
Full Usage:
this.setAppDetails (?appId, ?appIconPath, ?appIconIndex, ?relaunchCommand, ?relaunchDisplayName)
Parameters:
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.
|
Full Usage:
this.setAspectRatio (aspectRatio, ?extraSize)
Parameters:
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).
|
Full Usage:
this.setAutoHideCursor autoHide
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Controls whether to hide cursor when typing.
|
Full Usage:
this.setAutoHideMenuBar hide
Parameters:
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.
|
Full Usage:
this.setBackgroundColor backgroundColor
Parameters:
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.
|
|
⚠ 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.
|
Full Usage:
this.setBounds (bounds, ?animate)
Parameters:
Rectangle
?animate : bool
Modifiers: inline |
Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.> [!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.
|
Full Usage:
this.setClosable closable
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ Sets whether the window can be manually closed by user. On Linux does nothing.
|
Full Usage:
this.setContentBounds (bounds, ?animate)
Parameters:
Rectangle
?animate : bool
Modifiers: inline |
Resizes and moves the window's client area (e.g. the web page) to the supplied bounds.
|
Full Usage:
this.setContentProtection enable
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ Prevents the window contents from being captured by other apps.On macOS it sets the NSWindow's sharingType to NSWindowSharingNone. 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.
|
Full Usage:
this.setContentSize (width, height, ?animate)
Parameters:
int
height : int
?animate : bool
Modifiers: inline |
Resizes the window's client area (e.g. the web page) to width and height.
|
|
Sets the content view of the window.
|
Full Usage:
this.setDocumentEdited edited
Parameters:
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.
|
Full Usage:
this.setEnabled enable
Parameters:
bool
Modifiers: inline |
Disable or enable the window.
|
Full Usage:
this.setFocusable focusable
Parameters:
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.
|
Full Usage:
this.setFullScreen flag
Parameters:
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.
|
Full Usage:
this.setFullScreenable fullscreenable
Parameters:
bool
Modifiers: inline |
Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
|
Full Usage:
this.setHasShadow hasShadow
Parameters:
bool
Modifiers: inline |
Sets whether the window should have a shadow.
|
Full Usage:
this.setHiddenInMissionControl hidden
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Sets whether the window will be hidden when the user toggles into mission control.
|
|
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌ Changes window icon.
|
Full Usage:
this.setIgnoreMouseEvents (ignore, ?forward)
Parameters:
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.
|
Full Usage:
this.setKiosk flag
Parameters:
bool
Modifiers: inline |
Enters or leaves kiosk mode.
|
Full Usage:
this.setMaximizable maximizable
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ Sets whether the window can be manually maximized by user. On Linux does nothing.
|
Full Usage:
this.setMaximumSize (width, height)
Parameters:
int
height : int
Modifiers: inline |
Sets the maximum size of window to width and height.
|
|
|
Full Usage:
this.setMenuBarVisibility visible
Parameters:
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.
|
Full Usage:
this.setMinimizable minimizable
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ Sets whether the window can be manually minimized by user. On Linux does nothing.
|
Full Usage:
this.setMinimumSize (width, height)
Parameters:
int
height : int
Modifiers: inline |
Sets the minimum size of window to width and height.
|
Full Usage:
this.setMovable movable
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ Sets whether the window can be moved by user. On Linux does nothing.
|
Full Usage:
this.setOpacity opacity
Parameters:
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.
|
Full Usage:
this.setOverlayIcon (overlay, description)
Parameters:
Option<NativeImage>
description : string
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.
|
|
Sets parent as current window's parent window, passing null will turn current window into a top-level window.
|
Full Usage:
this.setPosition (x, y, ?animate)
Parameters:
int
y : int
?animate : bool
Modifiers: inline |
Moves window to x and y.
|
Full Usage:
this.setProgressBar (progress, ?options)
Parameters:
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.
|
Full Usage:
this.setRepresentedFilename filename
Parameters:
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.
|
Full Usage:
this.setResizable resizable
Parameters:
bool
Modifiers: inline |
Sets whether the window can be manually resized by the user.
|
|
⚠ 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.
|
Full Usage:
this.setSheetOffset (offsetY, ?offsetX)
Parameters:
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:
|
Full Usage:
this.setSimpleFullScreen flag
Parameters:
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).
|
Full Usage:
this.setSize (width, height, ?animate)
Parameters:
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.
|
Full Usage:
this.setSkipTaskbar skip
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌ Makes the window not show in the taskbar.
|
Full Usage:
this.setThumbarButtons buttons
Parameters:
ThumbarButton[]
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.
|
|
⚠ 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 }.
|
Full Usage:
this.setThumbnailToolTip toolTip
Parameters:
string
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌ Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar.
|
Full Usage:
this.setTitle title
Parameters:
string
Modifiers: inline |
Changes the title of native window to title.
|
Full Usage:
this.setTitleBarOverlay (?color, ?symbolColor, ?height)
Parameters:
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.
|
|
⚠ 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. |
|
|
Full Usage:
this.setVisibleOnAllWorkspaces (visible, ?visibleOnFullScreen, ?skipTransformProcessType)
Parameters:
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.
|
|
|
Full Usage:
this.setWindowButtonVisibility visible
Parameters:
bool
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Sets whether the window traffic light buttons should be visible.
|
Full Usage:
this.shadow
|
A boolean property that determines whether the window has a shadow. |
Full Usage:
this.show ()
Modifiers: inline |
Shows and gives focus to the window. |
Full Usage:
this.showAllTabs ()
Modifiers: inline |
⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ Shows or hides the tab overview when native tabs are enabled. |
Full Usage:
this.showInactive ()
Modifiers: inline |
Shows the window but doesn't focus on it. |
Full Usage:
this.simpleFullScreen
|
A boolean property that determines whether the window is in simple (pre-Lion) fullscreen mode. |
Full Usage:
this.snapped
Returns: bool
|
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌ A boolean property that indicates whether the window is arranged via Snap.
|
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.
|
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. |
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. |
Full Usage:
this.unhookAllWindowMessages ()
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌ Unhooks all of the window messages. |
Full Usage:
this.unhookWindowMessage message
Parameters:
int
Modifiers: inline |
⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌ Unhook the window message.
|
Full Usage:
this.unmaximize ()
Modifiers: inline |
Unmaximizes the window. |
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. |
Static members
| Static member |
Description
|
|
|
|
An array of all opened browser windows.
|
|
The window that is focused in this application, otherwise returns null.
|
fable-electron-docs-api