Skip to content

ElectronBrowserWindow

Unofficial

Electron BrowserWindow for creating and managing application windows.

Import:

import type { ElectronBrowserWindow } from '@obsidian-typings/obsidian-public-latest';

Signature:

export class ElectronBrowserWindow

Properties

PropertyTypeDescription
accessibleTitlestringAn alternative title provided only to accessibility tools such as screen readers. This string is not directly visible to users.
autoHideMenuBarbooleanWhether the window menu bar should hide itself automatically.
closablebooleanWhether the window can be manually closed by user. On Linux the setter is a no-op.
documentEditedbooleanWhether the window's document has been edited (macOS only).
excludedFromShownWindowsMenubooleanWhether the window is excluded from the application's Windows menu (macOS only).
focusablebooleanWhether the window is focusable (macOS and Windows).
fullScreenbooleanWhether the window is in fullscreen mode.
fullScreenablebooleanWhether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
idnumberThe unique identifier of the window, unique among all BrowserWindow instances of the entire application.
kioskbooleanWhether the window is in kiosk mode.
maximizablebooleanWhether the window can be manually maximized by user. On Linux the setter is a no-op.
menuBarVisiblebooleanWhether the menu bar should be visible (Windows and Linux).
minimizablebooleanWhether the window can be manually minimized by user. On Linux the setter is a no-op.
movablebooleanWhether the window can be moved by user. On Linux the setter is a no-op.
representedFilenamestringThe pathname of the file the window represents (macOS only).
resizablebooleanWhether the window can be manually resized by user.
shadowbooleanWhether the window has a shadow.
simpleFullScreenbooleanWhether the window is in simple (pre-Lion) fullscreen mode.
titlestringThe title of the native window.
visibleOnAllWorkspacesbooleanWhether the window is visible on all workspaces. Always returns false on Windows.
webContentsElectronWebContentsThe web contents owned by this window. All web page related events and operations will be done via it.

Methods

MethodReturnsDescription
addBrowserView(browserView)voidReplacement API for setBrowserView supporting work with multi browser views.
addListener(event, listener)thisRegisters a listener for the given window event.
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addListener(event, listener)this
addTabbedWindow(browserWindow)voidAdds a window as a tab on this window, after the tab for the window instance (macOS only).
blur()voidRemoves focus from the window.
blurWebView()voidRemoves focus from the web view.
capturePage(rect?)Promise<ElectronNativeImage>Captures a snapshot of the page within rect. Omitting rect will capture the whole visible page.
center()voidMoves window to the center of the screen.
close()voidTries to close the window. This has the same effect as a user manually clicking the close button.
closeFilePreview()voidCloses the currently open Quick Look panel (macOS only).
destroy()voidForce-closes the window; the unload and beforeunload events won't be emitted, but closed is guaranteed.
flashFrame(flag)voidStarts or stops flashing the window to attract user's attention.
focus()voidFocuses on the window.
focusOnWebView()voidFocuses on the web view.
fromBrowserView(browserView)ElectronBrowserWindow | nullReturns the window that owns the given browserView.
fromId(id)ElectronBrowserWindow | nullReturns the window with the given id.
fromWebContents(webContents)ElectronBrowserWindow | nullReturns the window that owns the given webContents.
getAllWindows()ElectronBrowserWindow[]Returns all opened browser windows.
getBackgroundColor()stringReturns the background color of the window in Hex (#RRGGBB) format.
getBounds()ElectronRectangleReturns the bounds of the window.
getBrowserView()ElectronBrowserView | nullReturns the BrowserView attached to this window.
getBrowserViews()ElectronBrowserView[]Returns all views attached with addBrowserView or setBrowserView.
getChildWindows()ElectronBrowserWindow[]Returns all child windows.
getContentBounds()ElectronRectangleReturns the bounds of the window's client area.
getContentSize()number[]Returns the window's client area's width and height.
getFocusedWindow()ElectronBrowserWindow | nullReturns the window that is focused in this application.
getMaximumSize()number[]Returns the window's maximum width and height.
getMediaSourceId()stringReturns the window id in the format of DesktopCapturerSource's id.
getMinimumSize()number[]Returns the window's minimum width and height.
getNativeWindowHandle()BufferReturns the platform-specific handle of the window.
getNormalBounds()ElectronRectangleReturns the window bounds of the normal state, regardless of the current window state.
getOpacity()numberReturns the opacity of the window, between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns 1.
getParentWindow()ElectronBrowserWindow | nullReturns the parent window.
getPosition()number[]Returns the window's current position.
getRepresentedFilename()stringReturns the pathname of the file the window represents (macOS only).
getSize()number[]Returns the window's width and height.
getTitle()stringReturns the title of the native window.
getTrafficLightPosition()ElectronPointReturns the custom position for the traffic light buttons in a frameless window (macOS only).
hasShadow()booleanReturns whether the window has a shadow.
hide()voidHides the window.
hookWindowMessage(message, callback)voidHooks a windows message. The callback is called when the message is received in the WndProc (Windows only).
isAlwaysOnTop()booleanReturns whether the window is always on top of other windows.
isClosable()booleanReturns whether the window can be manually closed by user. On Linux always returns true (macOS and Windows).
isDestroyed()booleanReturns whether the window has been destroyed.
isDocumentEdited()booleanReturns whether the window's document has been edited (macOS only).
isEnabled()booleanReturns whether the window is enabled.
isFocusable()voidReturns whether the window can be focused (macOS and Windows).
isFocused()booleanReturns whether the window is focused.
isFullScreen()booleanReturns whether the window is in fullscreen mode.
isFullScreenable()booleanReturns whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
isKiosk()booleanReturns whether the window is in kiosk mode.
isMaximizable()booleanReturns whether the window can be manually maximized by user. On Linux always returns true (macOS and Windows).
isMaximized()booleanReturns whether the window is maximized.
isMenuBarAutoHide()booleanReturns whether the menu bar automatically hides itself.
isMenuBarVisible()booleanReturns whether the menu bar is visible.
isMinimizable()booleanReturns whether the window can be manually minimized by user. On Linux always returns true (macOS and Windows).
isMinimized()booleanReturns whether the window is minimized.
isModal()booleanReturns whether the current window is a modal window.
isMovable()booleanReturns whether the window can be moved by user. On Linux always returns true (macOS and Windows).
isNormal()booleanReturns whether the window is in normal state (not maximized, not minimized, not in fullscreen mode).
isResizable()booleanReturns whether the window can be manually resized by user.
isSimpleFullScreen()booleanReturns whether the window is in simple (pre-Lion) fullscreen mode (macOS only).
isTabletMode()booleanReturns whether the window is in Windows 10 tablet mode (Windows only).
isVisible()booleanReturns whether the window is visible to the user.
isVisibleOnAllWorkspaces()booleanReturns whether the window is visible on all workspaces. Always returns false on Windows.
isWindowMessageHooked(message)booleanReturns whether the message is hooked (Windows only).
loadFile(filePath, options?)Promise<void>Loads a file into the window. Same as webContents.loadFile.
loadURL(url, options?)Promise<void>Loads a URL into the window. Same as webContents.loadURL.
maximize()voidMaximizes the window. This will also show (but not focus) the window if it isn't being displayed already.
mergeAllWindows()voidMerges all windows into one window with multiple tabs when native tabs are enabled (macOS only).
minimize()voidMinimizes the window. On some platforms the minimized window will be shown in the Dock.
moveAbove(mediaSourceId)voidMoves window above the source window in the sense of z-order.
moveTabToNewWindow()voidMoves the current tab into a new window if native tabs are enabled and there is more than one tab (macOS only).
moveTop()voidMoves window to top (z-order) regardless of focus.
on('always-on-top-changed', listener)thisRegisters a listener for the given window event.
on('app-command', listener)this
on('blur', listener)this
on('close', listener)this
on('closed', listener)this
on('enter-full-screen', listener)this
on('enter-html-full-screen', listener)this
on('focus', listener)this
on('hide', listener)this
on('leave-full-screen', listener)this
on('leave-html-full-screen', listener)this
on('maximize', listener)this
on('minimize', listener)this
on('move', listener)this
on('moved', listener)this
on('new-window-for-tab', listener)this
on('page-title-updated', listener)this
on('ready-to-show', listener)this
on('resize', listener)this
on('resized', listener)this
on('responsive', listener)this
on('restore', listener)this
on('rotate-gesture', listener)this
on('scroll-touch-begin', listener)this
on('scroll-touch-edge', listener)this
on('scroll-touch-end', listener)this
on('session-end', listener)this
on('sheet-begin', listener)this
on('sheet-end', listener)this
on('show', listener)this
on('swipe', listener)this
on('system-context-menu', listener)this
on('unmaximize', listener)this
on('unresponsive', listener)this
on('will-move', listener)this
on('will-resize', listener)this
once(event, listener)thisRegisters a one-time listener for the given window event.
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
once(event, listener)this
previewFile(path, displayName?)voidUses Quick Look to preview a file at a given path (macOS only).
reload()voidReloads the current page. Same as webContents.reload.
removeBrowserView(browserView)voidRemoves a view added with addBrowserView or setBrowserView.
removeListener(event, listener)thisRemoves a listener for the given window event.
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeListener(event, listener)this
removeMenu()voidRemoves the window's menu bar (Linux and Windows).
restore()voidRestores the window from minimized state to its previous state.
selectNextTab()voidSelects the next tab when native tabs are enabled and there are other tabs in the window (macOS only).
selectPreviousTab()voidSelects the previous tab when native tabs are enabled and there are other tabs in the window (macOS only).
setAlwaysOnTop(flag, level?, relativeLevel?)voidSets whether the window should show always on top of other windows.
setAppDetails(options)voidSets the properties for the window's taskbar button (Windows only).
setAspectRatio(aspectRatio, extraSize?)voidMakes the window maintain an aspect ratio.
setAutoHideCursor(autoHide)voidControls whether to hide the cursor when typing (macOS only).
setAutoHideMenuBar(hide)voidSets whether the window menu bar should hide itself automatically.
setBackgroundColor(backgroundColor)voidSets the background color of the window.
setBounds(bounds, animate?)voidResizes and moves the window to the supplied bounds. Any properties not supplied default to their current values.
setBrowserView(browserView)voidSets the view attached to the window.
setClosable(closable)voidSets whether the window can be manually closed by user. On Linux does nothing (macOS and Windows).
setContentBounds(bounds, animate?)voidResizes and moves the window's client area to the supplied bounds.
setContentProtection(enable)voidPrevents the window contents from being captured by other apps (macOS and Windows).
setContentSize(width, height, animate?)voidResizes the window's client area to width and height.
setDocumentEdited(edited)voidSpecifies whether the window's document has been edited (macOS only).
setEnabled(enable)voidDisables or enables the window.
setFocusable(focusable)voidChanges whether the window can be focused (macOS and Windows).
setFullScreen(flag)voidSets whether the window should be in fullscreen mode.
setFullScreenable(fullscreenable)voidSets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
setHasShadow(hasShadow)voidSets whether the window should have a shadow.
setIcon(icon)voidChanges the window icon (Linux and Windows).
setIgnoreMouseEvents(ignore, options?)voidMakes the window ignore all mouse events.
setKiosk(flag)voidEnters or leaves kiosk mode.
setMaximizable(maximizable)voidSets whether the window can be manually maximized by user. On Linux does nothing (macOS and Windows).
setMaximumSize(width, height)voidSets the maximum size of the window.
setMenu(menu)voidSets the menu as the window's menu bar (Linux and Windows).
setMenuBarVisibility(visible)voidSets whether the menu bar should be visible (Linux and Windows).
setMinimizable(minimizable)voidSets whether the window can be manually minimized by user. On Linux does nothing (macOS and Windows).
setMinimumSize(width, height)voidSets the minimum size of the window.
setMovable(movable)voidSets whether the window can be moved by user. On Linux does nothing (macOS and Windows).
setOpacity(opacity)voidSets the opacity of the window. On Linux, does nothing. Out of bound values are clamped to the [0, 1] range.
setOverlayIcon(overlay, description)voidSets a 16 x 16 pixel overlay onto the current taskbar icon (Windows only).
setParentWindow(parent)voidSets the parent window. Passing null will turn the current window into a top-level window.
setPosition(x, y, animate?)voidMoves the window to x and y.
setProgressBar(progress, options?)voidSets the progress value in the progress bar. Valid range is [0, 1.0].
setRepresentedFilename(filename)voidSets the pathname of the file the window represents (macOS only).
setResizable(resizable)voidSets whether the window can be manually resized by user.
setShape(rects)voidSets a window shape determining the area within the window where drawing and user interaction are permitted (Linux and Windows).
setSheetOffset(offsetY, offsetX?)voidChanges the attachment point for sheets on macOS (macOS only).
setSimpleFullScreen(flag)voidEnters or leaves simple fullscreen mode (macOS only).
setSize(width, height, animate?)voidResizes the window to width and height.
setSkipTaskbar(skip)voidMakes the window not show in the taskbar.
setThumbarButtons(buttons)booleanAdds a thumbnail toolbar with a specified set of buttons to the thumbnail image of a window (Windows only).
setThumbnailClip(region)voidSets the region of the window to show as the thumbnail image displayed when hovering over the window in the taskbar (Windows only).
setThumbnailToolTip(toolTip)voidSets the tooltip displayed when hovering over the window thumbnail in the taskbar (Windows only).
setTitle(title)voidChanges the title of the native window.
setTitleBarOverlay(options)voidOn a window with Window Controls Overlay already enabled, updates the style of the title bar overlay (Windows only).
setTopBrowserView(browserView)voidRaises browserView above other views attached to the window.
setTouchBar(touchBar)voidSets the touch bar layout for the current window. Specifying null or undefined clears the touch bar (macOS only).
setTrafficLightPosition(position)voidSets a custom position for the traffic light buttons in a frameless window (macOS only).
setVibrancy(type)voidAdds a vibrancy effect to the browser window. Passing null or an empty string removes the effect (macOS only).
setVisibleOnAllWorkspaces(visible, options?)voidSets whether the window should be visible on all workspaces. Does nothing on Windows.
setWindowButtonVisibility(visible)voidSets whether the window traffic light buttons should be visible (macOS only).
show()voidShows and gives focus to the window.
showDefinitionForSelection()voidShows the definition for the selected word (macOS only). Same as webContents.showDefinitionForSelection().
showInactive()voidShows the window but doesn't focus on it.
toggleTabBar()voidToggles the visibility of the tab bar if native tabs are enabled and there is only one tab (macOS only).
unhookAllWindowMessages()voidUnhooks all of the window messages (Windows only).
unhookWindowMessage(message)voidUnhooks the window message (Windows only).
unmaximize()voidUnmaximizes the window.

Links to this page: