new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Electron · API · all subjects

app/methods

526 notes in this subject, read out of this brain and free to use. This is page 9 of 9.

addTabbedWindow macOS method

addTabbedWindow(baseWindow: BaseWindow) is macOS-only and adds a window as a tab on this window, after the tab for the window instance.

setVibrancy macOS method

setVibrancy(type: string | null) is macOS-only and adds a vibrancy effect to the window. Passing null or an empty string will remove the vibrancy effect on the window. Valid type values are: titlebar, selection, menu, popover, sidebar, header, sheet, window, hud, fullscreen-ui, tooltip, content, under-window, and under-page.

setBackgroundMaterial Windows method

setBackgroundMaterial(material: string) is Windows-only and sets the browser window's system-drawn background material, including behind the non-client area. Valid material values are: auto (let the Desktop Window Manager automatically decide the system-drawn backdrop material for this window, this is the default), none (don't draw any system backdrop), mica (draw the backdrop material effect corresponding to a long-lived window), acrylic (draw the backdrop material effect corresponding to a transient window), and tabbed (draw the backdrop material effect corresponding to a window with a tabbed title bar). This method is only supported on Windows 11 22H2 and up.

setWindowButtonPosition and getWindowButtonPosition macOS methods

setWindowButtonPosition(position: Point | null) is macOS-only and sets a custom position for the traffic light buttons in frameless window. Passing null will reset the position to default. getWindowButtonPosition() is macOS-only and returns Point | null - the custom position for the traffic light buttons in frameless window. null will be returned when there is no custom position.

setTouchBar macOS method

setTouchBar(touchBar: TouchBar | null) is macOS-only and 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. The TouchBar API is currently experimental and may change or be removed in future Electron releases.

setTitleBarOverlay Windows Linux method

setTitleBarOverlay(options: Object) is available on Windows and Linux. It updates the style of the title bar overlay on a Window with Window Controls Overlay already enabled. The options object has: color (String, optional) - The CSS color of the Window Controls Overlay when enabled. symbolColor (String, optional) - The CSS color of the symbols on the Window Controls Overlay when enabled. height (Integer, optional) - The height of the title bar and Window Controls Overlay in pixels. On Linux, the symbolColor is automatically calculated to have minimum accessible contrast to the color if not explicitly set.

hookWindowMessage Windows method

hookWindowMessage(message: Integer, callback: Function) is Windows-only. It hooks a windows message. The callback is called when the message is received in the WndProc. The callback receives wParam (Buffer - the wParam provided to the WndProc) and lParam (Buffer - the lParam provided to the WndProc).

isWindowMessageHooked and unhookWindowMessage Windows methods

isWindowMessageHooked(message: Integer) is Windows-only and returns a boolean indicating whether the message is hooked. unhookWindowMessage(message: Integer) is Windows-only and unhooks the window message.

unhookAllWindowMessages Windows method

unhookAllWindowMessages() is Windows-only and unhooks all of the window messages.

setRepresentedFilename and getRepresentedFilename macOS methods

setRepresentedFilename(filename: string) is macOS-only and sets the pathname of the file the window represents. The icon of the file will show in window's title bar. getRepresentedFilename() is macOS-only and returns a string containing the pathname of the file the window represents.

setDocumentEdited and isDocumentEdited macOS methods

setDocumentEdited(edited: boolean) is macOS-only and specifies whether the window's document has been edited. The icon in title bar will become gray when set to true. isDocumentEdited() is macOS-only and returns a boolean indicating whether the window's document has been edited.

setMenu and removeMenu methods

setMenu(menu: Menu | null) is available on Linux and Windows. It sets the menu as the window's menu bar. removeMenu() is available on Linux and Windows and removes the window's menu bar.

setProgressBar method for progress display

setProgressBar(progress: Double, options?: Object) is available on Windows and macOS. It 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. The options parameter is optional and available on Windows. It has a mode property (string) that can be none, normal, indeterminate, error, or paused. If you call setProgressBar without a mode set (but with a value within the valid range), normal will be assumed.

setOverlayIcon Windows method

setOverlayIcon(overlay: NativeImage | null, description: string) is Windows-only. It 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. The overlay parameter is the icon to display on the bottom right corner of the taskbar icon. If this parameter is null, the overlay is cleared. The description parameter is a description that will be provided to Accessibility screen readers.

invalidateShadow macOS method

invalidateShadow() is macOS-only and 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.

setHasShadow and hasShadow methods

setHasShadow(hasShadow: boolean) sets whether the window should have a shadow. hasShadow() returns a boolean indicating whether the window has a shadow.

setOpacity and getOpacity methods

setOpacity(opacity: number) is available on Windows and macOS. It sets the opacity of the window to a value between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, does nothing. Out of bound number values are clamped to the [0, 1] range. getOpacity() returns a number between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns 1.

setShape method creates non-rectangular window

setShape(rects: Rectangle[]) is available on Windows and Linux (experimental). It sets a shape on the window. Passing an empty list reverts the window to being rectangular. 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.

setVisibleOnAllWorkspaces macOS Linux method

setVisibleOnAllWorkspaces(visible: boolean, options?: Object) is available on macOS and Linux. It sets whether the window should be visible on all workspaces. The options parameter is optional and has: visibleOnFullScreen (boolean, optional, macOS) - Sets whether the window should be visible above fullscreen windows. skipTransformProcessType (boolean, optional, macOS) - Calling setVisibleOnAllWorkspaces will by default transform the process type between UIElementApplication and ForegroundApplication to ensure the correct behavior. However, this will hide the window and dock for a short time every time it is called. If your window is already of type UIElementApplication, you can bypass this transformation by passing true to skipTransformProcessType. This API does nothing on Windows.

BaseWindow.fromId() static method

BaseWindow.fromId(id) where id is an Integer returns BaseWindow | null - the window with the given id.

setThumbnailClip Windows method

setThumbnailClip(region: Rectangle) is Windows-only. It 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 }.

setThumbnailToolTip Windows method

setThumbnailToolTip(toolTip: string) is Windows-only. It sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar.

setAppDetails Windows method parameters

setAppDetails(options: Object) is Windows-only. It sets the properties for the window's taskbar button. The options object has the following properties: appId (string, optional) - Window's App User Model ID. It has to be set, otherwise the other options will have no effect. appIconPath (string, optional) - Window's Relaunch Icon. appIconIndex (Integer, optional) - Index of the icon in appIconPath. Ignored when appIconPath is not set. Default is 0. relaunchCommand (string, optional) - Window's Relaunch Command. relaunchDisplayName (string, optional) - Window's Relaunch Display Name. Note: relaunchCommand and relaunchDisplayName must always be set together. If one of those properties is not set, then neither will be used.

setAccentColor Windows method with example

setAccentColor(accentColor: boolean | string | null) is Windows-only. It sets the system accent color and highlighting of active window border. By default, follows user preference in System Settings. To reset to system default, pass null. The accentColor parameter accepts: Color string - Like true, but 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 - Enable accent color highlighting for the window with the system accent color regardless of whether accent colors are enabled for windows in System Settings. false - Disable accent color highlighting for the window regardless of whether accent colors are currently enabled for windows in System Settings. null - Reset window accent color behavior to follow behavior set in System Settings. Example: const win = new BrowserWindow({ frame: false }); win.setAccentColor('#ff0000'); win.setAccentColor('rgba(255,0,0,0.5)'); win.setAccentColor(true); win.setAccentColor(false); win.setAccentColor(null)

getAccentColor Windows method

getAccentColor() is Windows-only. It returns a string | boolean representing 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.

setIcon method for window icon

setIcon(icon: NativeImage | string) is available on Windows and Linux. It changes window icon.

setWindowButtonVisibility macOS method

setWindowButtonVisibility(visible: boolean) is macOS-only. It sets whether the window traffic light buttons should be visible.

setAutoHideMenuBar method

setAutoHideMenuBar(hide: boolean) is available on Windows and Linux. It 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.

isMenuBarAutoHide and setMenuBarVisibility methods

isMenuBarAutoHide() is available on Windows and Linux and returns a boolean indicating whether menu bar automatically hides itself. setMenuBarVisibility(visible: boolean) is available on Windows and Linux and 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.

isMenuBarVisible Windows Linux method

isMenuBarVisible() is available on Windows and Linux and returns a boolean indicating whether the menu bar is visible.

isSnapped Windows method

isSnapped() is Windows-only and returns a boolean indicating 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.

isVisibleOnAllWorkspaces macOS Linux method

isVisibleOnAllWorkspaces() is available on macOS and Linux and returns a boolean indicating whether the window is visible on all workspaces. This API always returns false on Windows.

setIgnoreMouseEvents method with forwarding option

setIgnoreMouseEvents(ignore: boolean, options?: Object) 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. The options parameter is optional and has a forward property (boolean, optional, available on macOS and Windows). If true, forwards mouse move messages to Chromium, enabling mouse related events such as mouseleave. Only used when ignore is true. If ignore is false, forwarding is always disabled regardless of this value.

setContentProtection macOS Windows method

setContentProtection(enable: boolean) is available on macOS and Windows. It 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.

isContentProtected macOS Windows method

isContentProtected() is available on macOS and Windows and returns a boolean indicating whether or not content protection is currently enabled.

setFocusable and isFocusable methods

setFocusable(focusable: boolean) is available on macOS and Windows. It changes whether the window can be focused. On macOS it does not remove the focus from the window. isFocusable() is available on macOS and Windows and returns a boolean indicating whether the window can be focused.

setParentWindow and getParentWindow methods

setParentWindow(parent: BaseWindow | null) sets parent as current window's parent window. Passing null will turn current window into a top-level window. getParentWindow() returns BaseWindow | null, the parent window or null if there is no parent.

getChildWindows returns child windows array

getChildWindows() returns a BaseWindow[] containing all child windows.

setAutoHideCursor macOS method

setAutoHideCursor(autoHide: boolean) is macOS-only and controls whether to hide cursor when typing.

macOS native tabs methods

selectPreviousTab() is macOS-only and selects the previous tab when native tabs are enabled and there are other tabs in the window. selectNextTab() is macOS-only and selects the next tab when native tabs are enabled and there are other tabs in the window. showAllTabs() is macOS-only and shows or hides the tab overview when native tabs are enabled. mergeAllWindows() is macOS-only and merges all windows into one window with multiple tabs when native tabs are enabled and there is more than one open window. moveTabToNewWindow() is macOS-only and moves the current tab into a new window if native tabs are enabled and there is more than one tab in the current window. toggleTabBar() is macOS-only and toggles the visibility of the tab bar if native tabs are enabled and there is only one tab in the current window.

Main process native APIs

The main process adds custom APIs to interact with the user's operating system. Electron exposes various modules that control native desktop functionality, such as menus, dialogs, and tray icons.

Main process controls application lifecycle

The main process controls your application's lifecycle through Electron's app module. This module provides a large set of events and methods that you can use to add custom application behavior (for instance, programmatically quitting your application, modifying the application dock, or showing an About panel).

BrowserWindow destruction terminates renderer process

When a BrowserWindow instance is destroyed, its corresponding renderer process gets terminated as well.

BrowserWindow is EventEmitter

Because the BrowserWindow module is an EventEmitter, you can add handlers for various user events (for example, minimizing or maximizing your window).

Main process window management with BrowserWindow

The main process' primary purpose is to create and manage application windows with the BrowserWindow module. Each instance of the BrowserWindow class creates an application window that loads a web page in a separate renderer process. You can interact with this web content from the main process using the window's webContents object.

BrowserWindow example

const { BrowserWindow } = require('electron') const win = new BrowserWindow({ width: 800, height: 1500 }) win.loadURL('https://github.com') const contents = win.webContents console.log(contents)

Give your agent this brain

app/methods (9/9) — Electron · API