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 8 of 9.

BaseWindow.close() method

win.close() tries 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. See the close event.

BaseWindow.focus() method

win.focus() focuses on the window.

BaseWindow.blur() method

win.blur() removes focus from the window.

BaseWindow.isFocused() method

win.isFocused() returns boolean - whether the window is focused.

BaseWindow.isDestroyed() method

win.isDestroyed() returns boolean - whether the window is destroyed.

BaseWindow.show() method

win.show() shows and gives focus to the window.

BaseWindow.showInactive() method

win.showInactive() shows the window but doesn't focus on it.

BaseWindow.hide() method

win.hide() hides the window.

BaseWindow.isVisible() method

win.isVisible() returns boolean - whether the window is visible to the user in the foreground of the app.

BaseWindow.isModal() method

win.isModal() returns boolean - whether the current window is a modal window.

BaseWindow.maximize() method

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

BaseWindow.unmaximize() method

win.unmaximize() unmaximizes the window.

BaseWindow.isMaximized() method

win.isMaximized() returns boolean - whether the window is maximized.

BaseWindow.minimize() method

win.minimize() minimizes the window. On some platforms the minimized window will be shown in the Dock.

BaseWindow.restore() method

win.restore() restores the window from minimized state to its previous state.

BaseWindow.isMinimized() method

win.isMinimized() returns boolean - whether the window is minimized.

BaseWindow.setFullScreen() method

win.setFullScreen(flag) where flag is boolean sets whether the window should be in fullscreen mode. 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.

BaseWindow.isFullScreen() method

win.isFullScreen() returns boolean - whether the window is in fullscreen mode.

BaseWindow.setSimpleFullScreen() method (macOS)

win.setSimpleFullScreen(flag) where flag is boolean (macOS only) enters or leaves simple fullscreen mode. Simple fullscreen mode emulates the native fullscreen behavior found in versions of macOS prior to Lion (10.7).

BaseWindow.isSimpleFullScreen() method (macOS)

win.isSimpleFullScreen() (macOS only) returns boolean - whether the window is in simple (pre-Lion) fullscreen mode.

BaseWindow.isNormal() method

win.isNormal() returns boolean - whether the window is in normal state (not maximized, not minimized, not in fullscreen mode).

BaseWindow.setAspectRatio() method

win.setAspectRatio(aspectRatio[, extraSize]) where aspectRatio is Float (the aspect ratio to maintain) and extraSize is optional Size (macOS only, extra size not included in aspect ratio calculations). This makes a window maintain an aspect ratio. The aspect ratio is not respected when window is resized programmatically with APIs like setSize. To reset an aspect ratio, pass 0 as the aspectRatio value.

BaseWindow.setBackgroundColor() method

win.setBackgroundColor(backgroundColor) where backgroundColor is string sets the background color of the window. Valid formats: Hex (#fff, #ffff, #ffffff, #ffffffff), RGB (rgb(255, 255, 255)), RGBA (rgba(255, 255, 255, 1.0)), HSL (hsl(200, 20%, 50%)), HSLA (hsla(200, 20%, 50%, 0.5)), or CSS color names (case-sensitive, as listed in SkParseColor.cpp).

BaseWindow.previewFile() method (macOS)

win.previewFile(path[, displayName]) (macOS only) where path is string (absolute path to file to preview with QuickLook) and displayName is optional string (name of file to display on Quick Look modal, purely visual, defaults to path). Uses Quick Look to preview a file at the given path.

BaseWindow.closeFilePreview() method (macOS)

win.closeFilePreview() (macOS only) closes the currently open Quick Look panel.

BaseWindow.setBounds() macOS y-coordinate constraint

On macOS, the y-coordinate value in setBounds cannot be smaller than the Tray height, which has changed over time and depends on OS but is between 20-40px. Passing a value lower than tray height will result in a window that is flush to the tray.

BaseWindow.getBounds() method

win.getBounds() returns Rectangle - the bounds of the window as an Object. On macOS, the y-coordinate value returned will be at minimum the Tray height. On Wayland, this method will return { x: 0, y: 0, ... } as introspecting or programmatically changing global window coordinates is prohibited.

BaseWindow.getBackgroundColor() method

win.getBackgroundColor() returns string - gets the background color of the window in Hex (#RRGGBB) format. The alpha value is not returned alongside the red, green, and blue values.

BaseWindow.setContentBounds() method

win.setContentBounds(bounds[, animate]) where bounds is Rectangle and animate is optional boolean (macOS only) resizes and moves the window's client area (e.g. the web page) to the supplied bounds.

BaseWindow.getContentBounds() method

win.getContentBounds() returns Rectangle - the bounds of the window's client area as an Object.

BaseWindow.getNormalBounds() method

win.getNormalBounds() returns Rectangle - contains the window bounds of the normal state.

getNormalBounds returns normal state bounds regardless of current state

getNormalBounds always returns the position and size of the window in normal state. In normal state, getBounds and getNormalBounds return the same Rectangle. This is true regardless of whether the window is currently maximized, minimized, or in fullscreen.

setEnabled and isEnabled methods

setEnabled(enable: boolean) disables or enables the window. isEnabled() returns a boolean indicating whether the window is enabled.

setSize window resize method

setSize(width: Integer, height: Integer, animate?: boolean) resizes the window to the specified width and height. The animate parameter is optional and macOS-only. If width or height are below any set minimum size constraints, the window snaps to its minimum size.

getSize returns window dimensions

getSize() returns an Integer[] containing the window's width and height.

setContentSize and getContentSize methods

setContentSize(width: Integer, height: Integer, animate?: boolean) resizes the window's client area (e.g. the web page) to the specified dimensions. The animate parameter is optional and macOS-only. getContentSize() returns an Integer[] containing the client area's width and height.

setMinimumSize and getMinimumSize methods

setMinimumSize(width: Integer, height: Integer) sets the minimum size of the window. getMinimumSize() returns an Integer[] containing the window's minimum width and height.

setMaximumSize and getMaximumSize methods

setMaximumSize(width: Integer, height: Integer) sets the maximum size of the window. getMaximumSize() returns an Integer[] containing the window's maximum width and height.

setResizable and isResizable methods

setResizable(resizable: boolean) sets whether the window can be manually resized by the user. isResizable() returns a boolean indicating whether the window can be manually resized by the user.

setMovable platform availability and behavior

setMovable(movable: boolean) is available on macOS and Windows. It sets whether the window can be moved by user. On Linux this method does nothing. isMovable() returns a boolean on macOS and Windows indicating whether the window can be moved by user. On Linux isMovable() always returns true.

setMinimizable platform availability and behavior

setMinimizable(minimizable: boolean) is available on macOS and Windows. It sets whether the window can be manually minimized by user. On Linux this method does nothing. isMinimizable() returns a boolean on macOS and Windows indicating whether the window can be manually minimized by the user. On Linux isMinimizable() always returns true.

setMaximizable platform availability and behavior

setMaximizable(maximizable: boolean) is available on macOS and Windows. It sets whether the window can be manually maximized by user. On Linux this method does nothing. isMaximizable() returns a boolean on macOS and Windows indicating whether the window can be manually maximized by user. On Linux isMaximizable() always returns true.

setFullScreenable and isFullScreenable methods

setFullScreenable(fullscreenable: boolean) sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. isFullScreenable() returns a boolean indicating whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

setClosable platform availability and behavior

setClosable(closable: boolean) is available on macOS and Windows. It sets whether the window can be manually closed by user. On Linux this method does nothing. isClosable() returns a boolean on macOS and Windows indicating whether the window can be manually closed by user. On Linux isClosable() always returns true.

setHiddenInMissionControl macOS method

setHiddenInMissionControl(hidden: boolean) is macOS-only and sets whether the window will be hidden when the user toggles into mission control. isHiddenInMissionControl() is macOS-only and returns a boolean indicating whether the window will be hidden when the user toggles into mission control.

setAlwaysOnTop method and levels

setAlwaysOnTop(flag: boolean, level?: string, relativeLevel?: Integer) sets whether the window should show always on top of other windows. The level parameter is optional and available on macOS and Windows. Valid level values are: normal, floating, torn-off-menu, modal-panel, main-menu, status, pop-up-menu, screen-saver, and dock (deprecated). The default level is floating when flag is true. The level is reset to normal when the flag is false. On macOS and Windows, from floating to status inclusive, the window is placed below the Dock on macOS and below the taskbar on Windows. From pop-up-menu to higher, it is shown above the Dock on macOS and above the taskbar on Windows. The relativeLevel parameter is optional and macOS-only, specifying the number of layers higher to set this window relative to the given level. The default is 0. Apple discourages setting levels higher than 1 above screen-saver. This method is not supported on Wayland (Linux).

isAlwaysOnTop returns always-on-top state

isAlwaysOnTop() returns a boolean indicating whether the window is always on top of other windows. This method is not supported on Wayland (Linux).

moveAbove method with mediaSourceId

moveAbove(mediaSourceId: string) moves window above the source window in the sense of z-order. The mediaSourceId is a string in the format of DesktopCapturerSource's id, for example 'window:1869:0'. If the mediaSourceId is not of type window or if the window does not exist, this method throws an error.

moveTop method z-order

moveTop() moves window to top (z-order) regardless of focus.

center method centers window

center() moves window to the center of the screen.

setPosition moves window to coordinates

setPosition(x: Integer, y: Integer, animate?: boolean) moves window to the specified x and y coordinates. The animate parameter is optional and macOS-only.

getPosition returns window coordinates

getPosition() returns an Integer[] containing the window's current position. On Wayland, this method will return [0, 0] as introspecting or programmatically changing the global window coordinates is prohibited.

setTitle and getTitle methods

setTitle(title: string) changes the title of the native window. getTitle() returns a string containing the title of the native window. The title of the web page can be different from the title of the native window.

setSheetOffset macOS method with example

setSheetOffset(offsetY: Float, offsetX?: Float) is macOS-only and 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. Example: const { BaseWindow } = require('electron'); const win = new BaseWindow(); const toolbarRect = document.getElementById('toolbar').getBoundingClientRect(); win.setSheetOffset(toolbarRect.height)

flashFrame method starts or stops flashing window

flashFrame(flag: boolean) starts or stops flashing the window to attract user's attention. On macOS, flashFrame(bool) will flash dock icon continuously.

setSkipTaskbar hides window from taskbar

setSkipTaskbar(skip: boolean) is available on macOS and Windows. It makes the window not show in the taskbar.

setKiosk and isKiosk methods

setKiosk(flag: boolean) enters or leaves kiosk mode. isKiosk() returns a boolean indicating whether the window is in kiosk mode.

isTabletMode Windows method

isTabletMode() is Windows-only and returns a boolean indicating whether the window is in Windows 10 tablet mode. On Windows 10, users can use their PC as a tablet, and under this mode apps can choose to optimize their UI for tablets, such as enlarging the titlebar and hiding titlebar buttons. The resize event can be used to listen to changes to tablet mode.

getMediaSourceId returns window ID

getMediaSourceId() returns a string representing the 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.

getNativeWindowHandle returns platform-specific handle

getNativeWindowHandle() returns a Buffer containing 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.

Give your agent this brain