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/events

156 notes in this subject, read out of this brain and free to use. This is page 2 of 3.

ServiceWorkers running-status-changed event

The 'running-status-changed' event is experimental and emitted when a service worker's running status has changed. It returns a details object containing versionId (number - ID of the updated service worker version) and runningStatus (string - possible values: starting, running, stopping, or stopped).

KeyboardEvent Object structure

The KeyboardEvent object contains the following optional boolean properties: ctrlKey (whether the Control key was used in an accelerator), metaKey (whether a meta key was used in an accelerator), shiftKey (whether a Shift key was used in an accelerator), altKey (whether an Alt key was used in an accelerator), and triggeredByAccelerator (whether an accelerator was used to trigger the event as opposed to another user gesture like mouse click).

Windows shutdown vs reboot differentiation limitation

On Windows, the 'shutdown' reason is triggered for both shutdown and reboot scenarios because Windows does not offer a way to differentiate between them.

Event: accent-color-changed on Windows and Linux

The systemPreferences object emits an 'accent-color-changed' event on Windows and Linux. The event callback receives the event object and a newColor string parameter containing the new RGBA color the user assigned to be their system accent color.

Event: color-changed on Windows

The systemPreferences object emits a 'color-changed' event on Windows. The event callback receives the event object.

Tray 'mouse-up' event

The 'mouse-up' event is emitted when the mouse is released from clicking the tray icon on macOS. It returns event (KeyboardEvent) and position (Point). This event will not be emitted if a context menu is set for the Tray using tray.setContextMenu due to macOS-level constraints.

Tray 'click' event

The 'click' event is emitted when the tray icon is clicked. It returns event (KeyboardEvent), bounds (Rectangle), and position (Point). On Linux, this event is emitted when the tray icon receives activation, which might not necessarily be left mouse click.

Tray 'right-click' event

The 'right-click' event is emitted when the tray icon is right clicked on macOS and Windows. It returns event (KeyboardEvent) and bounds (Rectangle).

Tray 'double-click' event

The 'double-click' event is emitted when the tray icon is double clicked on macOS and Windows. It returns event (KeyboardEvent) and bounds (Rectangle).

Tray 'middle-click' event

The 'middle-click' event is emitted when the tray icon is middle clicked on Windows. It returns event (KeyboardEvent) and bounds (Rectangle).

Tray 'balloon-show' event

The 'balloon-show' event is emitted when the tray balloon shows on Windows.

Tray 'balloon-click' event

The 'balloon-click' event is emitted when the tray balloon is clicked on Windows.

Tray 'balloon-closed' event

The 'balloon-closed' event is emitted when the tray balloon is closed because of timeout or the user manually closes it on Windows.

Tray 'drop' event

The 'drop' event is emitted when any dragged items are dropped on the tray icon on macOS.

Tray 'drop-files' event

The 'drop-files' event is emitted when dragged files are dropped in the tray icon on macOS. It returns event (Event) and files (string array) containing the paths of the dropped files.

Tray 'drop-text' event

The 'drop-text' event is emitted when dragged text is dropped in the tray icon on macOS. It returns event (Event) and text (string) containing the dropped text string.

Tray 'drag-enter' event

The 'drag-enter' event is emitted when a drag operation enters the tray icon on macOS.

Tray 'drag-leave' event

The 'drag-leave' event is emitted when a drag operation exits the tray icon on macOS.

Tray 'drag-end' event

The 'drag-end' event is emitted when a drag operation ends on the tray or ends at another location on macOS.

Tray 'mouse-down' event

The 'mouse-down' event is emitted when the mouse clicks the tray icon on macOS. It returns event (KeyboardEvent) and position (Point).

Tray 'mouse-enter' event

The 'mouse-enter' event is emitted when the mouse enters the tray icon on macOS and Windows. It returns event (KeyboardEvent) and position (Point).

Tray 'mouse-leave' event

The 'mouse-leave' event is emitted when the mouse exits the tray icon on macOS and Windows. It returns event (KeyboardEvent) and position (Point).

Tray 'mouse-move' event

The 'mouse-move' event is emitted when the mouse moves in the tray icon on macOS and Windows. It returns event (KeyboardEvent) and position (Point).

UtilityProcess exit event

The exit event is emitted after the child process ends. Returns code (number) containing the exit code for the process obtained from waitpid on POSIX or GetExitCodeProcess on Windows.

UtilityProcess message event

The message event is emitted when the child process sends a message using process.parentPort.postMessage(). Returns message (any type).

UtilityProcess login event

The login event is emitted when the utility process encounters an HTTP 401 or 407 authentication challenge, if the process was created with both respondToAuthRequestsFromMainProcess: true and a session option. Returns authenticationResponseDetails (Object with url (URL), pid (number), isRequestForNavigation (boolean), firstAuthAttempt (boolean), responseHeaders (optional Record<string, string | string[]>)); authInfo (Object with isProxy (boolean), scheme (string), host (string), port (Integer), realm (string)); and callback (Function taking optional username (string) and password (string)). The callback should be called with credentials to respond to the challenge. Calling callback without arguments cancels the request. Behaves the same as the login event on app but is scoped to the individual utility process instance.

UtilityProcess login event example

const { session, utilityProcess } = require('electron') const ses = session.defaultSession const child = utilityProcess.fork('./worker.js', [], { session: ses, respondToAuthRequestsFromMainProcess: true }) child.on('login', (authenticationResponseDetails, authInfo, callback) => { callback('username', 'password') }) This example shows handling the login event on a utility process by responding with credentials.

UtilityProcess spawn event

The spawn event is emitted once the child process has spawned successfully.

UtilityProcess error event

The error event (experimental) is emitted when the child process needs to terminate due to non-continuable error from V8. Returns type (string, one of 'FatalError'), location (string from where error originated), and report (string Node.js diagnostic report). The exit event will be emitted after the child process terminates regardless of whether the error event is listened to.

WebContentsView requires app ready event

The WebContentsView module cannot be used until the ready event of the app module is emitted.

View bounds-changed event

The 'bounds-changed' event is emitted when the view's bounds have changed in response to being laid out. The new bounds can be retrieved with view.getBounds().

WebFrameMain dom-ready event

The dom-ready event is emitted when the document is loaded.

webFrame isolated-world-created event

The 'isolated-world-created' event is emitted when a new isolated world is created for webFrame. The event returns a worldId (Integer) representing the ID of the isolated world that was just created. This event does not fire for the main world (ID 0) or Electron's preload world (ID 999).

webview page-favicon-updated event

Event fired when page receives favicon urls. Returns: favicons (string[] - array of URLs).

webview leave-html-full-screen event

Event fired when page leaves fullscreen triggered by HTML API.

webview console-message event

Event fired when the guest window logs a console message. Returns: level (Integer - the log level, from 0 to 3, in order: verbose, info, warning, error), message (string - the actual console message), line (Integer - the line number of the source that triggered this console message), sourceId (string).

webview found-in-page event

Event fired when a result is available for webview.findInPage request. Returns: result (Object) with requestId (Integer), activeMatchOrdinal (Integer - position of the active match), matches (Integer - number of matches), selectionArea (Rectangle - coordinates of first match region), finalUpdate (boolean).

webview will-navigate event

Event emitted when a user or the page wants to start navigation. Returns: url (string). It can happen when the window.location object is changed or a user clicks a link in the page. This event will not emit when the navigation is started programmatically with APIs like webview.loadURL and webview.back. It is also not emitted during in-page navigation, such as clicking anchor links or updating window.location.hash. Calling event.preventDefault() does NOT have any effect.

webview will-frame-navigate event

Event emitted when a user or the page wants to start navigation anywhere in the webview or any frames embedded within. Returns: url (string), isMainFrame (boolean), frameProcessId (Integer), frameRoutingId (Integer). This event will not emit when the navigation is started programmatically with APIs like webview.loadURL and webview.back. It is also not emitted during in-page navigation. Calling event.preventDefault() does NOT have any effect.

webview did-start-navigation event

Event emitted when any frame (including main) starts navigating. Returns: url (string), isInPlace (boolean - true for in-page navigations), isMainFrame (boolean), frameProcessId (Integer), frameRoutingId (Integer).

webview did-redirect-navigation event

Event emitted after a server side redirect occurs during navigation, for example a 302 redirect. Returns: url (string), isInPlace (boolean), isMainFrame (boolean), frameProcessId (Integer), frameRoutingId (Integer).

webview did-frame-navigate event

Event emitted when any frame navigation is done. Returns: url (string), httpResponseCode (Integer - -1 for non HTTP navigations), httpStatusText (string - empty for non HTTP navigations), isMainFrame (boolean), frameProcessId (Integer), frameRoutingId (Integer). This event is not emitted for in-page navigations.

webview close event

Event fired when the guest page attempts to close itself.

webview render-process-gone event

Event fired when the renderer process unexpectedly disappears. Returns: details (RenderProcessGoneDetails structure). This is normally because it was crashed or killed.

webview destroyed event

Event fired when the WebContents is destroyed.

webview media-started-playing event

Event emitted when media starts playing.

webview media-paused event

Event emitted when media is paused or done playing.

webview did-change-theme-color event

Event emitted when a page's theme color changes. Returns: themeColor (string). This is usually due to encountering a meta tag like <meta name='theme-color' content='#ff0000'>.

webview update-target-url event

Event emitted when mouse moves over a link or the keyboard moves the focus to a link. Returns: url (string).

webview devtools-focused event

Event emitted when DevTools is focused or opened.

webview context-menu event

Event emitted when there is a new context menu that needs to be handled. Returns: params (Object) with x (Integer - x coordinate), y (Integer - y coordinate), linkURL (string - URL of the link that encloses the node the context menu was invoked on), linkText (string - text associated with the link, may be empty string if contents are an image), pageURL (string - URL of the top level page), frameURL (string - URL of the subframe), srcURL (string - source URL for the element), mediaType (string - type of node, can be none, image, audio, video, canvas, file or plugin), hasImageContents (boolean), isEditable (boolean), selectionText (string), titleText (string), altText (string), suggestedFilename (string), selectionRect (Rectangle), selectionStartOffset (number), referrerPolicy (Referrer structure), misspelledWord (string), dictionarySuggestions (string[]), frameCharset (string), formControlType (string), spellcheckEnabled (boolean), menuSourceType (string - can be none, mouse, keyboard, touch, touchMenu, longPress, longTap, touchHandle, stylus, adjustSelection, or adjustSelectionReset), mediaFlags (Object) with inError, isPaused, isMuted, hasAudio, isLooping, isControlsVisible, canToggleControls, canPrint, canSave, canShowPictureInPicture, isShowingPictureInPicture, canRotate, canLoop (all boolean), editFlags (Object) with canUndo, canRedo, canCut, canCopy, canPaste, canDelete, canSelectAll, canEditRichly (all boolean).

webview example console message forwarding

Example showing how to forward all console messages from guest page to embedder's console: const webview = document.querySelector('webview'); webview.addEventListener('console-message', (e) => { console.log('Guest page logged a message:', e.message); });

webview example found-in-page with stopFindInPage

Example showing how to use findInPage and stopFindInPage: const webview = document.querySelector('webview'); webview.addEventListener('found-in-page', (e) => { webview.stopFindInPage('keepSelection'); }); const requestId = webview.findInPage('test'); console.log(requestId);

webview example close event handling

Example showing how to handle the close event by navigating webview to about:blank: const webview = document.querySelector('webview'); webview.addEventListener('close', () => { webview.src = 'about:blank'; });

webview did-navigate event

Event emitted when a navigation is done. Returns: url (string). This event is not emitted for in-page navigations, such as clicking anchor links or updating window.location.hash. Use did-navigate-in-page event for this purpose.

webview load-commit event

Event fired when a load has committed. Returns: url (string), isMainFrame (boolean). This includes navigation within the current document as well as subframe document-level loads, but does not include asynchronous resource loads.

webview did-finish-load event

Event fired when the navigation is done, i.e. the spinner of the tab will stop spinning, and the onload event is dispatched.

webview did-fail-load event

Event fired when the load failed or was cancelled, e.g. window.stop() is invoked. Returns: errorCode (Integer), errorDescription (string), validatedURL (string), isMainFrame (boolean).

webview did-frame-finish-load event

Event fired when a frame has done navigation. Returns: isMainFrame (boolean).

webview did-start-loading event

Event corresponds to the points in time when the spinner of the tab starts spinning.

Give your agent this brain