Merge branch 'master' into chrome52
This commit is contained in:
commit
b57665330c
203 changed files with 2352 additions and 1220 deletions
|
@ -179,7 +179,12 @@ Returns:
|
|||
* `error` String - The error code
|
||||
* `certificate` Object
|
||||
* `data` Buffer - PEM encoded data
|
||||
* `issuerName` String
|
||||
* `issuerName` String - Issuer's Common Name
|
||||
* `subjectName` String - Subject's Common Name
|
||||
* `serialNumber` String - Hex value represented string
|
||||
* `validStart` Integer - Start date of the certificate being valid in seconds
|
||||
* `validExpiry` Integer - End date of the certificate being valid in seconds
|
||||
* `fingerprint` String - Fingerprint of the certificate
|
||||
* `callback` Function
|
||||
|
||||
Emitted when failed to verify the `certificate` for `url`, to trust the
|
||||
|
@ -208,6 +213,11 @@ Returns:
|
|||
* `certificateList` [Objects]
|
||||
* `data` Buffer - PEM encoded data
|
||||
* `issuerName` String - Issuer's Common Name
|
||||
* `subjectName` String - Subject's Common Name
|
||||
* `serialNumber` String - Hex value represented string
|
||||
* `validStart` Integer - Start date of the certificate being valid in seconds
|
||||
* `validExpiry` Integer - End date of the certificate being valid in seconds
|
||||
* `fingerprint` String - Fingerprint of the certificate
|
||||
* `callback` Function
|
||||
|
||||
Emitted when a client certificate is requested.
|
||||
|
@ -259,6 +269,19 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
|
|||
|
||||
Emitted when the gpu process crashes.
|
||||
|
||||
### Event: 'accessibility-support-changed' _macOS_ _Windows_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `accessibilitySupportEnabled` Boolean - `true` when Chrome's accessibility
|
||||
support is enabled, `false` otherwise.
|
||||
|
||||
Emitted when Chrome's accessibility support changes. This event fires when
|
||||
assistive technologies, such as screen readers, are enabled or disabled.
|
||||
See https://www.chromium.org/developers/design-documents/accessibility for more
|
||||
details.
|
||||
|
||||
## Methods
|
||||
|
||||
The `app` object has the following methods:
|
||||
|
@ -397,7 +420,7 @@ Overrides the current application's name.
|
|||
### `app.getLocale()`
|
||||
|
||||
Returns the current application locale. Possible return values are documented
|
||||
[here](app-locales.md).
|
||||
[here](locales.md).
|
||||
|
||||
**Note:** When distributing your packaged app, you have to also ship the
|
||||
`locales` folder.
|
||||
|
@ -598,6 +621,44 @@ Returns the current value displayed in the counter badge.
|
|||
|
||||
Returns whether current desktop environment is Unity launcher.
|
||||
|
||||
### `app.getLoginItemSettings()` _macOS_ _Windows_
|
||||
|
||||
Return an Object with the login item settings of the app.
|
||||
|
||||
* `openAtLogin` Boolean - `true` if the app is set to open at login.
|
||||
* `openAsHidden` Boolean - `true` if the app is set to open as hidden at login.
|
||||
This setting is only supported on macOS.
|
||||
* `wasOpenedAtLogin` Boolean - `true` if the app was opened at login
|
||||
automatically. This setting is only supported on macOS.
|
||||
* `wasOpenedAsHidden` Boolean - `true` if the app was opened as a hidden login
|
||||
item. This indicates that the app should not open any windows at startup.
|
||||
This setting is only supported on macOS.
|
||||
* `restoreState` Boolean - `true` if the app was opened as a login item that
|
||||
should restore the state from the previous session. This indicates that the
|
||||
app should restore the windows that were open the last time the app was
|
||||
closed. This setting is only supported on macOS.
|
||||
|
||||
### `app.setLoginItemSettings(settings)` _macOS_ _Windows_
|
||||
|
||||
* `settings` Object
|
||||
* `openAtLogin` Boolean - `true` to open the app at login, `false` to remove
|
||||
the app as a login item. Defaults to `false`.
|
||||
* `openAsHidden` Boolean - `true` to open the app as hidden. Defaults to
|
||||
`false`. The user can edit this setting from the System Preferences so
|
||||
`app.getLoginItemStatus().wasOpenedAsHidden` should be checked when the app
|
||||
is opened to know the current value. This setting is only supported on
|
||||
macOS.
|
||||
|
||||
Set the app's login item settings.
|
||||
|
||||
### `app.isAccessibilitySupportEnabled()` _macOS_ _Windows_
|
||||
|
||||
Returns a `Boolean`, `true` if Chrome's accessibility support is enabled,
|
||||
`false` otherwise. This API will return `true` if the use of assistive
|
||||
technologies, such as screen readers, has been detected. See
|
||||
https://www.chromium.org/developers/design-documents/accessibility for more
|
||||
details.
|
||||
|
||||
### `app.commandLine.appendSwitch(switch[, value])`
|
||||
|
||||
Append a switch (with optional `value`) to Chromium's command line.
|
||||
|
|
|
@ -100,6 +100,10 @@ The `autoUpdater` object has the following methods:
|
|||
|
||||
Sets the `url` and initialize the auto updater.
|
||||
|
||||
### `autoUpdater.getFeedURL()`
|
||||
|
||||
Returns the current update feed URL.
|
||||
|
||||
### `autoUpdater.checkForUpdates()`
|
||||
|
||||
Asks the server whether there is an update. You must call `setFeedURL` before
|
||||
|
|
|
@ -174,16 +174,19 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
|||
this below.
|
||||
* `titleBarStyle` String - The style of window title bar. See more about this
|
||||
below.
|
||||
* `thickFrame` Boolean - Use `WS_THICKFRAME` style for frameless windows on
|
||||
Windows, which adds standard window frame. Setting it to `false` will remove
|
||||
window shadow and window animations. Default is `true`.
|
||||
* `webPreferences` Object - Settings of web page's features. See more about
|
||||
this below.
|
||||
|
||||
When setting minimum or maximum window size with `minWidth`/`maxWidth`/
|
||||
`minHeight`/`maxHeight`, it only constrains the users, it won't prevent you from
|
||||
`minHeight`/`maxHeight`, it only constrains the users. It won't prevent you from
|
||||
passing a size that does not follow size constraints to `setBounds`/`setSize` or
|
||||
to the constructor of `BrowserWindow`.
|
||||
|
||||
The possible values and behaviors of `type` option are platform dependent,
|
||||
supported values are:
|
||||
The possible values and behaviors of the `type` option are platform dependent.
|
||||
Possible values are:
|
||||
|
||||
* On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`,
|
||||
`notification`.
|
||||
|
@ -194,6 +197,7 @@ supported values are:
|
|||
(`kCGDesktopWindowLevel - 1`). Note that desktop window will not receive
|
||||
focus, keyboard or mouse events, but you can use `globalShortcut` to receive
|
||||
input sparingly.
|
||||
* On Windows, possible type is `toolbar`.
|
||||
|
||||
The `titleBarStyle` option is only supported on macOS 10.10 Yosemite and newer.
|
||||
Possible values are:
|
||||
|
@ -206,7 +210,7 @@ Possible values are:
|
|||
* `hidden-inset` results in a hidden title bar with an alternative look
|
||||
where the traffic light buttons are slightly more inset from the window edge.
|
||||
|
||||
The `webPreferences` option is an object that can have following properties:
|
||||
The `webPreferences` option is an object that can have the following properties:
|
||||
|
||||
* `nodeIntegration` Boolean - Whether node integration is enabled. Default
|
||||
is `true`.
|
||||
|
@ -220,24 +224,24 @@ The `webPreferences` option is an object that can have following properties:
|
|||
* `session` [Session](session.md#class-session) - Sets the session used by the
|
||||
page. Instead of passing the Session object directly, you can also choose to
|
||||
use the `partition` option instead, which accepts a partition string. When
|
||||
both `session` and `partition` are provided, `session` would be preferred.
|
||||
both `session` and `partition` are provided, `session` will be preferred.
|
||||
Default is the default session.
|
||||
* `partition` String - Sets the session used by the page according to the
|
||||
session's partition string. If `partition` starts with `persist:`, the page
|
||||
will use a persistent session available to all pages in the app with the
|
||||
same `partition`. if there is no `persist:` prefix, the page will use an
|
||||
same `partition`. If there is no `persist:` prefix, the page will use an
|
||||
in-memory session. By assigning the same `partition`, multiple pages can share
|
||||
the same session. Default is the default session.
|
||||
* `zoomFactor` Number - The default zoom factor of the page, `3.0` represents
|
||||
`300%`. Default is `1.0`.
|
||||
* `javascript` Boolean - Enables JavaScript support. Default is `true`.
|
||||
* `webSecurity` Boolean - When setting `false`, it will disable the
|
||||
same-origin policy (Usually using testing websites by people), and set
|
||||
* `webSecurity` Boolean - When `false`, it will disable the
|
||||
same-origin policy (usually using testing websites by people), and set
|
||||
`allowDisplayingInsecureContent` and `allowRunningInsecureContent` to
|
||||
`true` if these two options are not set by user. Default is `true`.
|
||||
* `allowDisplayingInsecureContent` Boolean - Allow an https page to display
|
||||
content like images from http URLs. Default is `false`.
|
||||
* `allowRunningInsecureContent` Boolean - Allow a https page to run
|
||||
* `allowRunningInsecureContent` Boolean - Allow an https page to run
|
||||
JavaScript, CSS or plugins from http URLs. Default is `false`.
|
||||
* `images` Boolean - Enables image support. Default is `true`.
|
||||
* `textAreasAreResizable` Boolean - Make TextArea elements resizable. Default
|
||||
|
@ -271,23 +275,23 @@ The `webPreferences` option is an object that can have following properties:
|
|||
* `backgroundThrottling` Boolean - Whether to throttle animations and timers
|
||||
when the page becomes background. Defaults to `true`.
|
||||
|
||||
## Events
|
||||
### Instance Events
|
||||
|
||||
The `BrowserWindow` object emits the following events:
|
||||
Objects created with `new BrowserWindow` emit the following events:
|
||||
|
||||
**Note:** Some events are only available on specific operating systems and are
|
||||
labeled as such.
|
||||
|
||||
### Event: 'page-title-updated'
|
||||
#### Event: 'page-title-updated'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
|
||||
Emitted when the document changed its title, calling `event.preventDefault()`
|
||||
would prevent the native window's title to change.
|
||||
will prevent the native window's title from changing.
|
||||
|
||||
### Event: 'close'
|
||||
#### Event: 'close'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -314,87 +318,87 @@ window.onbeforeunload = (e) => {
|
|||
};
|
||||
```
|
||||
|
||||
### Event: 'closed'
|
||||
#### Event: 'closed'
|
||||
|
||||
Emitted when the window is closed. After you have received this event you should
|
||||
remove the reference to the window and avoid using it anymore.
|
||||
remove the reference to the window and avoid using it any more.
|
||||
|
||||
### Event: 'unresponsive'
|
||||
#### Event: 'unresponsive'
|
||||
|
||||
Emitted when the web page becomes unresponsive.
|
||||
|
||||
### Event: 'responsive'
|
||||
#### Event: 'responsive'
|
||||
|
||||
Emitted when the unresponsive web page becomes responsive again.
|
||||
|
||||
### Event: 'blur'
|
||||
#### Event: 'blur'
|
||||
|
||||
Emitted when the window loses focus.
|
||||
|
||||
### Event: 'focus'
|
||||
#### Event: 'focus'
|
||||
|
||||
Emitted when the window gains focus.
|
||||
|
||||
### Event: 'show'
|
||||
#### Event: 'show'
|
||||
|
||||
Emitted when the window is shown.
|
||||
|
||||
### Event: 'hide'
|
||||
#### Event: 'hide'
|
||||
|
||||
Emitted when the window is hidden.
|
||||
|
||||
### Event: 'ready-to-show'
|
||||
#### Event: 'ready-to-show'
|
||||
|
||||
Emitted when the web page has been rendered and window can be displayed without
|
||||
visual flash.
|
||||
a visual flash.
|
||||
|
||||
### Event: 'maximize'
|
||||
#### Event: 'maximize'
|
||||
|
||||
Emitted when window is maximized.
|
||||
|
||||
### Event: 'unmaximize'
|
||||
#### Event: 'unmaximize'
|
||||
|
||||
Emitted when the window exits from maximized state.
|
||||
Emitted when the window exits from a maximized state.
|
||||
|
||||
### Event: 'minimize'
|
||||
#### Event: 'minimize'
|
||||
|
||||
Emitted when the window is minimized.
|
||||
|
||||
### Event: 'restore'
|
||||
#### Event: 'restore'
|
||||
|
||||
Emitted when the window is restored from minimized state.
|
||||
Emitted when the window is restored from a minimized state.
|
||||
|
||||
### Event: 'resize'
|
||||
#### Event: 'resize'
|
||||
|
||||
Emitted when the window is getting resized.
|
||||
Emitted when the window is being resized.
|
||||
|
||||
### Event: 'move'
|
||||
#### Event: 'move'
|
||||
|
||||
Emitted when the window is getting moved to a new position.
|
||||
Emitted when the window is being moved to a new position.
|
||||
|
||||
__Note__: On macOS this event is just an alias of `moved`.
|
||||
|
||||
### Event: 'moved' _macOS_
|
||||
#### Event: 'moved' _macOS_
|
||||
|
||||
Emitted once when the window is moved to a new position.
|
||||
|
||||
### Event: 'enter-full-screen'
|
||||
#### Event: 'enter-full-screen'
|
||||
|
||||
Emitted when the window enters full screen state.
|
||||
Emitted when the window enters a full-screen state.
|
||||
|
||||
### Event: 'leave-full-screen'
|
||||
#### Event: 'leave-full-screen'
|
||||
|
||||
Emitted when the window leaves full screen state.
|
||||
Emitted when the window leaves a full-screen state.
|
||||
|
||||
### Event: 'enter-html-full-screen'
|
||||
#### Event: 'enter-html-full-screen'
|
||||
|
||||
Emitted when the window enters full screen state triggered by html api.
|
||||
Emitted when the window enters a full-screen state triggered by HTML API.
|
||||
|
||||
### Event: 'leave-html-full-screen'
|
||||
#### Event: 'leave-html-full-screen'
|
||||
|
||||
Emitted when the window leaves full screen state triggered by html api.
|
||||
Emitted when the window leaves a full-screen state triggered by HTML API.
|
||||
|
||||
### Event: 'app-command' _Windows_
|
||||
#### Event: 'app-command' _Windows_
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -405,8 +409,8 @@ Emitted when an [App Command](https://msdn.microsoft.com/en-us/library/windows/d
|
|||
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 with underscores replaced with hyphens and the
|
||||
`APPCOMMAND_` prefix stripped off.
|
||||
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`.
|
||||
|
||||
```javascript
|
||||
|
@ -418,15 +422,15 @@ someWindow.on('app-command', (e, cmd) => {
|
|||
});
|
||||
```
|
||||
|
||||
### Event: 'scroll-touch-begin' _macOS_
|
||||
#### Event: 'scroll-touch-begin' _macOS_
|
||||
|
||||
Emitted when scroll wheel event phase has begun.
|
||||
|
||||
### Event: 'scroll-touch-end' _macOS_
|
||||
#### Event: 'scroll-touch-end' _macOS_
|
||||
|
||||
Emitted when scroll wheel event phase has ended.
|
||||
|
||||
### Event: 'swipe' _macOS_
|
||||
#### Event: 'swipe' _macOS_
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -435,31 +439,31 @@ Returns:
|
|||
|
||||
Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
|
||||
|
||||
## Methods
|
||||
### Static Methods
|
||||
|
||||
The `BrowserWindow` object has the following methods:
|
||||
The `BrowserWindow` class has the following static methods:
|
||||
|
||||
### `BrowserWindow.getAllWindows()`
|
||||
#### `BrowserWindow.getAllWindows()`
|
||||
|
||||
Returns an array of all opened browser windows.
|
||||
|
||||
### `BrowserWindow.getFocusedWindow()`
|
||||
#### `BrowserWindow.getFocusedWindow()`
|
||||
|
||||
Returns the window that is focused in this application, otherwise returns `null`.
|
||||
|
||||
### `BrowserWindow.fromWebContents(webContents)`
|
||||
#### `BrowserWindow.fromWebContents(webContents)`
|
||||
|
||||
* `webContents` [WebContents](web-contents.md)
|
||||
|
||||
Find a window according to the `webContents` it owns.
|
||||
|
||||
### `BrowserWindow.fromId(id)`
|
||||
#### `BrowserWindow.fromId(id)`
|
||||
|
||||
* `id` Integer
|
||||
|
||||
Find a window according to its ID.
|
||||
|
||||
### `BrowserWindow.addDevToolsExtension(path)`
|
||||
#### `BrowserWindow.addDevToolsExtension(path)`
|
||||
|
||||
* `path` String
|
||||
|
||||
|
@ -470,21 +474,21 @@ API is not for programming use. If you try to add an extension that has already
|
|||
been loaded, this method will not return and instead log a warning to the
|
||||
console.
|
||||
|
||||
Method will also not return if the extension's manifest is missing or incomplete.
|
||||
The method will also not return if the extension's manifest is missing or incomplete.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
### `BrowserWindow.removeDevToolsExtension(name)`
|
||||
#### `BrowserWindow.removeDevToolsExtension(name)`
|
||||
|
||||
* `name` String
|
||||
|
||||
Remove the DevTools extension whose name is `name`.
|
||||
Remove a DevTools extension by name.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
### `BrowserWindow.getDevToolsExtensions()`
|
||||
#### `BrowserWindow.getDevToolsExtensions()`
|
||||
|
||||
Returns an Object where the keys are the extension names and each value is
|
||||
an Object containing `name` and `version` properties.
|
||||
|
@ -498,7 +502,7 @@ let installed = BrowserWindow.getDevToolsExtensions().hasOwnProperty('devtron')
|
|||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
## Instance Properties
|
||||
### Instance Properties
|
||||
|
||||
Objects created with `new BrowserWindow` have the following properties:
|
||||
|
||||
|
@ -507,114 +511,114 @@ Objects created with `new BrowserWindow` have the following properties:
|
|||
let win = new BrowserWindow({width: 800, height: 600});
|
||||
```
|
||||
|
||||
### `win.webContents`
|
||||
#### `win.webContents`
|
||||
|
||||
The `WebContents` object this window owns, all web page related events and
|
||||
The `WebContents` object this window owns. All web page related events and
|
||||
operations will be done via it.
|
||||
|
||||
See the [`webContents` documentation](web-contents.md) for its methods and
|
||||
events.
|
||||
|
||||
### `win.id`
|
||||
#### `win.id`
|
||||
|
||||
The unique ID of this window.
|
||||
The unique ID of the window.
|
||||
|
||||
## Instance Methods
|
||||
### Instance Methods
|
||||
|
||||
Objects created with `new BrowserWindow` have the following instance methods:
|
||||
|
||||
**Note:** Some methods are only available on specific operating systems and are
|
||||
labeled as such.
|
||||
|
||||
### `win.destroy()`
|
||||
#### `win.destroy()`
|
||||
|
||||
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.
|
||||
|
||||
### `win.close()`
|
||||
#### `win.close()`
|
||||
|
||||
Try to close the window, this has the same effect with user manually clicking
|
||||
the close button of the window. The web page may cancel the close though, see
|
||||
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](#event-close).
|
||||
|
||||
### `win.focus()`
|
||||
#### `win.focus()`
|
||||
|
||||
Focuses on the window.
|
||||
|
||||
### `win.blur()`
|
||||
#### `win.blur()`
|
||||
|
||||
Removes focus from the window.
|
||||
|
||||
### `win.isFocused()`
|
||||
#### `win.isFocused()`
|
||||
|
||||
Returns a boolean, whether the window is focused.
|
||||
|
||||
### `win.show()`
|
||||
#### `win.show()`
|
||||
|
||||
Shows and gives focus to the window.
|
||||
|
||||
### `win.showInactive()`
|
||||
#### `win.showInactive()`
|
||||
|
||||
Shows the window but doesn't focus on it.
|
||||
|
||||
### `win.hide()`
|
||||
#### `win.hide()`
|
||||
|
||||
Hides the window.
|
||||
|
||||
### `win.isVisible()`
|
||||
#### `win.isVisible()`
|
||||
|
||||
Returns a boolean, whether the window is visible to the user.
|
||||
|
||||
### `win.isModal()`
|
||||
#### `win.isModal()`
|
||||
|
||||
Returns whether current window is a modal window.
|
||||
Returns a boolean, whether current window is a modal window.
|
||||
|
||||
### `win.maximize()`
|
||||
#### `win.maximize()`
|
||||
|
||||
Maximizes the window.
|
||||
|
||||
### `win.unmaximize()`
|
||||
#### `win.unmaximize()`
|
||||
|
||||
Unmaximizes the window.
|
||||
|
||||
### `win.isMaximized()`
|
||||
#### `win.isMaximized()`
|
||||
|
||||
Returns a boolean, whether the window is maximized.
|
||||
|
||||
### `win.minimize()`
|
||||
#### `win.minimize()`
|
||||
|
||||
Minimizes the window. On some platforms the minimized window will be shown in
|
||||
the Dock.
|
||||
|
||||
### `win.restore()`
|
||||
#### `win.restore()`
|
||||
|
||||
Restores the window from minimized state to its previous state.
|
||||
|
||||
### `win.isMinimized()`
|
||||
#### `win.isMinimized()`
|
||||
|
||||
Returns a boolean, whether the window is minimized.
|
||||
|
||||
### `win.setFullScreen(flag)`
|
||||
#### `win.setFullScreen(flag)`
|
||||
|
||||
* `flag` Boolean
|
||||
|
||||
Sets whether the window should be in fullscreen mode.
|
||||
|
||||
### `win.isFullScreen()`
|
||||
#### `win.isFullScreen()`
|
||||
|
||||
Returns a boolean, whether the window is in fullscreen mode.
|
||||
|
||||
### `win.setAspectRatio(aspectRatio[, extraSize])` _macOS_
|
||||
#### `win.setAspectRatio(aspectRatio[, extraSize])` _macOS_
|
||||
|
||||
* `aspectRatio` The aspect ratio we want to maintain for some portion of the
|
||||
* `aspectRatio` The aspect ratio to maintain for some portion of the
|
||||
content view.
|
||||
* `extraSize` Object (optional) - The extra size not to be included while
|
||||
maintaining the aspect ratio.
|
||||
* `width` Integer
|
||||
* `height` Integer
|
||||
|
||||
This will have a window maintain an aspect ratio. The extra size allows a
|
||||
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.
|
||||
|
@ -628,7 +632,7 @@ the player itself we would call this function with arguments of 16/9 and
|
|||
are within the content view--only that they exist. Just sum any extra width and
|
||||
height areas you have within the overall content view.
|
||||
|
||||
### `win.setBounds(options[, animate])`
|
||||
#### `win.setBounds(options[, animate])`
|
||||
|
||||
* `options` Object
|
||||
* `x` Integer
|
||||
|
@ -639,11 +643,11 @@ height areas you have within the overall content view.
|
|||
|
||||
Resizes and moves the window to `width`, `height`, `x`, `y`.
|
||||
|
||||
### `win.getBounds()`
|
||||
#### `win.getBounds()`
|
||||
|
||||
Returns an object that contains window's width, height, x and y values.
|
||||
|
||||
### `win.setSize(width, height[, animate])`
|
||||
#### `win.setSize(width, height[, animate])`
|
||||
|
||||
* `width` Integer
|
||||
* `height` Integer
|
||||
|
@ -651,11 +655,11 @@ Returns an object that contains window's width, height, x and y values.
|
|||
|
||||
Resizes the window to `width` and `height`.
|
||||
|
||||
### `win.getSize()`
|
||||
#### `win.getSize()`
|
||||
|
||||
Returns an array that contains window's width and height.
|
||||
|
||||
### `win.setContentSize(width, height[, animate])`
|
||||
#### `win.setContentSize(width, height[, animate])`
|
||||
|
||||
* `width` Integer
|
||||
* `height` Integer
|
||||
|
@ -663,101 +667,101 @@ Returns an array that contains window's width and height.
|
|||
|
||||
Resizes the window's client area (e.g. the web page) to `width` and `height`.
|
||||
|
||||
### `win.getContentSize()`
|
||||
#### `win.getContentSize()`
|
||||
|
||||
Returns an array that contains window's client area's width and height.
|
||||
|
||||
### `win.setMinimumSize(width, height)`
|
||||
#### `win.setMinimumSize(width, height)`
|
||||
|
||||
* `width` Integer
|
||||
* `height` Integer
|
||||
|
||||
Sets the minimum size of window to `width` and `height`.
|
||||
|
||||
### `win.getMinimumSize()`
|
||||
#### `win.getMinimumSize()`
|
||||
|
||||
Returns an array that contains window's minimum width and height.
|
||||
|
||||
### `win.setMaximumSize(width, height)`
|
||||
#### `win.setMaximumSize(width, height)`
|
||||
|
||||
* `width` Integer
|
||||
* `height` Integer
|
||||
|
||||
Sets the maximum size of window to `width` and `height`.
|
||||
|
||||
### `win.getMaximumSize()`
|
||||
#### `win.getMaximumSize()`
|
||||
|
||||
Returns an array that contains window's maximum width and height.
|
||||
|
||||
### `win.setResizable(resizable)`
|
||||
#### `win.setResizable(resizable)`
|
||||
|
||||
* `resizable` Boolean
|
||||
|
||||
Sets whether the window can be manually resized by user.
|
||||
|
||||
### `win.isResizable()`
|
||||
#### `win.isResizable()`
|
||||
|
||||
Returns whether the window can be manually resized by user.
|
||||
|
||||
### `win.setMovable(movable)` _macOS_ _Windows_
|
||||
#### `win.setMovable(movable)` _macOS_ _Windows_
|
||||
|
||||
* `movable` Boolean
|
||||
|
||||
Sets whether the window can be moved by user. On Linux does nothing.
|
||||
|
||||
### `win.isMovable()` _macOS_ _Windows_
|
||||
#### `win.isMovable()` _macOS_ _Windows_
|
||||
|
||||
Returns whether the window can be moved by user. On Linux always returns
|
||||
`true`.
|
||||
|
||||
### `win.setMinimizable(minimizable)` _macOS_ _Windows_
|
||||
#### `win.setMinimizable(minimizable)` _macOS_ _Windows_
|
||||
|
||||
* `minimizable` Boolean
|
||||
|
||||
Sets whether the window can be manually minimized by user. On Linux does
|
||||
nothing.
|
||||
|
||||
### `win.isMinimizable()` _macOS_ _Windows_
|
||||
#### `win.isMinimizable()` _macOS_ _Windows_
|
||||
|
||||
Returns whether the window can be manually minimized by user. On Linux always
|
||||
returns `true`.
|
||||
|
||||
### `win.setMaximizable(maximizable)` _macOS_ _Windows_
|
||||
#### `win.setMaximizable(maximizable)` _macOS_ _Windows_
|
||||
|
||||
* `maximizable` Boolean
|
||||
|
||||
Sets whether the window can be manually maximized by user. On Linux does
|
||||
nothing.
|
||||
|
||||
### `win.isMaximizable()` _macOS_ _Windows_
|
||||
#### `win.isMaximizable()` _macOS_ _Windows_
|
||||
|
||||
Returns whether the window can be manually maximized by user. On Linux always
|
||||
returns `true`.
|
||||
|
||||
### `win.setFullScreenable(fullscreenable)`
|
||||
#### `win.setFullScreenable(fullscreenable)`
|
||||
|
||||
* `fullscreenable` Boolean
|
||||
|
||||
Sets whether the maximize/zoom window button toggles fullscreen mode or
|
||||
maximizes the window.
|
||||
|
||||
### `win.isFullScreenable()`
|
||||
#### `win.isFullScreenable()`
|
||||
|
||||
Returns whether the maximize/zoom window button toggles fullscreen mode or
|
||||
maximizes the window.
|
||||
|
||||
### `win.setClosable(closable)` _macOS_ _Windows_
|
||||
#### `win.setClosable(closable)` _macOS_ _Windows_
|
||||
|
||||
* `closable` Boolean
|
||||
|
||||
Sets whether the window can be manually closed by user. On Linux does nothing.
|
||||
|
||||
### `win.isClosable()` _macOS_ _Windows_
|
||||
#### `win.isClosable()` _macOS_ _Windows_
|
||||
|
||||
Returns whether the window can be manually closed by user. On Linux always
|
||||
returns `true`.
|
||||
|
||||
### `win.setAlwaysOnTop(flag)`
|
||||
#### `win.setAlwaysOnTop(flag)`
|
||||
|
||||
* `flag` Boolean
|
||||
|
||||
|
@ -765,15 +769,15 @@ 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.
|
||||
|
||||
### `win.isAlwaysOnTop()`
|
||||
#### `win.isAlwaysOnTop()`
|
||||
|
||||
Returns whether the window is always on top of other windows.
|
||||
|
||||
### `win.center()`
|
||||
#### `win.center()`
|
||||
|
||||
Moves window to the center of the screen.
|
||||
|
||||
### `win.setPosition(x, y[, animate])`
|
||||
#### `win.setPosition(x, y[, animate])`
|
||||
|
||||
* `x` Integer
|
||||
* `y` Integer
|
||||
|
@ -781,24 +785,24 @@ Moves window to the center of the screen.
|
|||
|
||||
Moves window to `x` and `y`.
|
||||
|
||||
### `win.getPosition()`
|
||||
#### `win.getPosition()`
|
||||
|
||||
Returns an array that contains window's current position.
|
||||
|
||||
### `win.setTitle(title)`
|
||||
#### `win.setTitle(title)`
|
||||
|
||||
* `title` String
|
||||
|
||||
Changes the title of native window to `title`.
|
||||
|
||||
### `win.getTitle()`
|
||||
#### `win.getTitle()`
|
||||
|
||||
Returns the title of the native window.
|
||||
|
||||
**Note:** The title of web page can be different from the title of the native
|
||||
window.
|
||||
|
||||
### `win.setSheetOffset(offsetY[, offsetX])` _macOS_
|
||||
#### `win.setSheetOffset(offsetY[, offsetX])` _macOS_
|
||||
|
||||
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
|
||||
|
@ -809,36 +813,36 @@ let toolbarRect = document.getElementById('toolbar').getBoundingClientRect();
|
|||
win.setSheetOffset(toolbarRect.height);
|
||||
```
|
||||
|
||||
### `win.flashFrame(flag)`
|
||||
#### `win.flashFrame(flag)`
|
||||
|
||||
* `flag` Boolean
|
||||
|
||||
Starts or stops flashing the window to attract user's attention.
|
||||
|
||||
### `win.setSkipTaskbar(skip)`
|
||||
#### `win.setSkipTaskbar(skip)`
|
||||
|
||||
* `skip` Boolean
|
||||
|
||||
Makes the window not show in the taskbar.
|
||||
|
||||
### `win.setKiosk(flag)`
|
||||
#### `win.setKiosk(flag)`
|
||||
|
||||
* `flag` Boolean
|
||||
|
||||
Enters or leaves the kiosk mode.
|
||||
|
||||
### `win.isKiosk()`
|
||||
#### `win.isKiosk()`
|
||||
|
||||
Returns whether the window is in kiosk mode.
|
||||
|
||||
### `win.getNativeWindowHandle()`
|
||||
#### `win.getNativeWindowHandle()`
|
||||
|
||||
Returns the platform-specific handle of the window as `Buffer`.
|
||||
|
||||
The native type of the handle is `HWND` on Windows, `NSView*` on macOS, and
|
||||
`Window` (`unsigned long`) on Linux.
|
||||
|
||||
### `win.hookWindowMessage(message, callback)` _Windows_
|
||||
#### `win.hookWindowMessage(message, callback)` _Windows_
|
||||
|
||||
* `message` Integer
|
||||
* `callback` Function
|
||||
|
@ -846,78 +850,68 @@ The native type of the handle is `HWND` on Windows, `NSView*` on macOS, and
|
|||
Hooks a windows message. The `callback` is called when
|
||||
the message is received in the WndProc.
|
||||
|
||||
### `win.isWindowMessageHooked(message)` _Windows_
|
||||
#### `win.isWindowMessageHooked(message)` _Windows_
|
||||
|
||||
* `message` Integer
|
||||
|
||||
Returns `true` or `false` depending on whether the message is hooked.
|
||||
|
||||
### `win.unhookWindowMessage(message)` _Windows_
|
||||
#### `win.unhookWindowMessage(message)` _Windows_
|
||||
|
||||
* `message` Integer
|
||||
|
||||
Unhook the window message.
|
||||
|
||||
### `win.unhookAllWindowMessages()` _Windows_
|
||||
#### `win.unhookAllWindowMessages()` _Windows_
|
||||
|
||||
Unhooks all of the window messages.
|
||||
|
||||
### `win.setRepresentedFilename(filename)` _macOS_
|
||||
#### `win.setRepresentedFilename(filename)` _macOS_
|
||||
|
||||
* `filename` String
|
||||
|
||||
Sets the pathname of the file the window represents, and the icon of the file
|
||||
will show in window's title bar.
|
||||
|
||||
### `win.getRepresentedFilename()` _macOS_
|
||||
#### `win.getRepresentedFilename()` _macOS_
|
||||
|
||||
Returns the pathname of the file the window represents.
|
||||
|
||||
### `win.setDocumentEdited(edited)` _macOS_
|
||||
#### `win.setDocumentEdited(edited)` _macOS_
|
||||
|
||||
* `edited` Boolean
|
||||
|
||||
Specifies whether the window’s document has been edited, and the icon in title
|
||||
bar will become gray when set to `true`.
|
||||
|
||||
### `win.isDocumentEdited()` _macOS_
|
||||
#### `win.isDocumentEdited()` _macOS_
|
||||
|
||||
Whether the window's document has been edited.
|
||||
|
||||
### `win.focusOnWebView()`
|
||||
#### `win.focusOnWebView()`
|
||||
|
||||
### `win.blurWebView()`
|
||||
#### `win.blurWebView()`
|
||||
|
||||
### `win.capturePage([rect, ]callback)`
|
||||
#### `win.capturePage([rect, ]callback)`
|
||||
|
||||
* `rect` Object (optional) - The area of page to be captured
|
||||
* `x` Integer
|
||||
* `y` Integer
|
||||
* `width` Integer
|
||||
* `height` Integer
|
||||
* `callback` Function
|
||||
Same as `webContents.capturePage([rect, ]callback)`.
|
||||
|
||||
Captures a snapshot of the page within `rect`. Upon completion `callback` will
|
||||
be called with `callback(image)`. The `image` is an instance of
|
||||
[NativeImage](native-image.md) that stores data of the snapshot. Omitting
|
||||
`rect` will capture the whole visible page.
|
||||
|
||||
### `win.loadURL(url[, options])`
|
||||
#### `win.loadURL(url[, options])`
|
||||
|
||||
Same as `webContents.loadURL(url[, options])`.
|
||||
|
||||
### `win.reload()`
|
||||
#### `win.reload()`
|
||||
|
||||
Same as `webContents.reload`.
|
||||
|
||||
### `win.setMenu(menu)` _Linux_ _Windows_
|
||||
#### `win.setMenu(menu)` _Linux_ _Windows_
|
||||
|
||||
* `menu` Menu
|
||||
|
||||
Sets the `menu` as the window's menu bar, setting it to `null` will remove the
|
||||
menu bar.
|
||||
|
||||
### `win.setProgressBar(progress)`
|
||||
#### `win.setProgressBar(progress)`
|
||||
|
||||
* `progress` Double
|
||||
|
||||
|
@ -930,7 +924,7 @@ 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.getName().desktop`.
|
||||
|
||||
### `win.setOverlayIcon(overlay, description)` _Windows 7+_
|
||||
#### `win.setOverlayIcon(overlay, description)` _Windows_
|
||||
|
||||
* `overlay` [NativeImage](native-image.md) - the icon to display on the bottom
|
||||
right corner of the taskbar icon. If this parameter is `null`, the overlay is
|
||||
|
@ -941,19 +935,19 @@ screen readers
|
|||
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.
|
||||
|
||||
### `win.setHasShadow(hasShadow)` _macOS_
|
||||
#### `win.setHasShadow(hasShadow)` _macOS_
|
||||
|
||||
* `hasShadow` Boolean
|
||||
|
||||
Sets whether the window should have a shadow. On Windows and Linux does
|
||||
nothing.
|
||||
|
||||
### `win.hasShadow()` _macOS_
|
||||
#### `win.hasShadow()` _macOS_
|
||||
|
||||
Returns whether the window has a shadow. On Windows and Linux always returns
|
||||
`true`.
|
||||
|
||||
### `win.setThumbarButtons(buttons)` _Windows 7+_
|
||||
#### `win.setThumbarButtons(buttons)` _Windows_
|
||||
|
||||
* `buttons` Array
|
||||
|
||||
|
@ -989,17 +983,30 @@ The `flags` is an array that can include following `String`s:
|
|||
button state is drawn. This value is intended for instances where the button
|
||||
is used in a notification.
|
||||
|
||||
### `win.showDefinitionForSelection()` _macOS_
|
||||
#### `win.setThumbnailClip(region)` _Windows_
|
||||
|
||||
* `region` - Object
|
||||
* `x` Integer - x-position of region
|
||||
* `y` Integer - y-position of region
|
||||
* `width` Integer - width of region
|
||||
* `height` Integer - height of region
|
||||
|
||||
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}`.
|
||||
|
||||
#### `win.showDefinitionForSelection()` _macOS_
|
||||
|
||||
Same as `webContents.showDefinitionForSelection()`.
|
||||
|
||||
### `win.setIcon(icon)` _Windows_ _Linux_
|
||||
#### `win.setIcon(icon)` _Windows_ _Linux_
|
||||
|
||||
* `icon` [NativeImage](native-image.md)
|
||||
|
||||
Changes window icon.
|
||||
|
||||
### `win.setAutoHideMenuBar(hide)`
|
||||
#### `win.setAutoHideMenuBar(hide)`
|
||||
|
||||
* `hide` Boolean
|
||||
|
||||
|
@ -1009,22 +1016,22 @@ 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.
|
||||
|
||||
### `win.isMenuBarAutoHide()`
|
||||
#### `win.isMenuBarAutoHide()`
|
||||
|
||||
Returns whether menu bar automatically hides itself.
|
||||
|
||||
### `win.setMenuBarVisibility(visible)`
|
||||
#### `win.setMenuBarVisibility(visible)`
|
||||
|
||||
* `visible` Boolean
|
||||
|
||||
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.
|
||||
|
||||
### `win.isMenuBarVisible()`
|
||||
#### `win.isMenuBarVisible()`
|
||||
|
||||
Returns whether the menu bar is visible.
|
||||
|
||||
### `win.setVisibleOnAllWorkspaces(visible)`
|
||||
#### `win.setVisibleOnAllWorkspaces(visible)`
|
||||
|
||||
* `visible` Boolean
|
||||
|
||||
|
@ -1032,13 +1039,13 @@ Sets whether the window should be visible on all workspaces.
|
|||
|
||||
**Note:** This API does nothing on Windows.
|
||||
|
||||
### `win.isVisibleOnAllWorkspaces()`
|
||||
#### `win.isVisibleOnAllWorkspaces()`
|
||||
|
||||
Returns whether the window is visible on all workspaces.
|
||||
|
||||
**Note:** This API always returns false on Windows.
|
||||
|
||||
### `win.setIgnoreMouseEvents(ignore)`
|
||||
#### `win.setIgnoreMouseEvents(ignore)`
|
||||
|
||||
* `ignore` Boolean
|
||||
|
||||
|
@ -1048,14 +1055,14 @@ 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.
|
||||
|
||||
### `win.setContentProtection(enable)` _macOS_ _Windows_
|
||||
#### `win.setContentProtection(enable)` _macOS_ _Windows_
|
||||
|
||||
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_MONITOR.
|
||||
|
||||
### `win.setFocusable(focusable)` _Windows_
|
||||
#### `win.setFocusable(focusable)` _Windows_
|
||||
|
||||
* `focusable` Boolean
|
||||
|
||||
|
@ -1063,17 +1070,17 @@ Changes whether the window can be focused.
|
|||
|
||||
[blink-feature-string]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
|
||||
|
||||
### `win.setParentWindow(parent)` _Linux_ _macOS_
|
||||
#### `win.setParentWindow(parent)` _Linux_ _macOS_
|
||||
|
||||
* `parent` BrowserWindow
|
||||
|
||||
Sets `parent` as current window's parent window, passing `null` will turn
|
||||
current window into a top-level window.
|
||||
|
||||
### `win.getParentWindow()`
|
||||
#### `win.getParentWindow()`
|
||||
|
||||
Returns the parent window.
|
||||
|
||||
### `win.getChildWindows()`
|
||||
#### `win.getChildWindows()`
|
||||
|
||||
Returns all child windows.
|
||||
|
|
|
@ -32,8 +32,8 @@ The `dialog` module has the following methods:
|
|||
left empty the default label will be used.
|
||||
* `filters` Array
|
||||
* `properties` Array - Contains which features the dialog should use, can
|
||||
contain `openFile`, `openDirectory`, `multiSelections` and
|
||||
`createDirectory`
|
||||
contain `openFile`, `openDirectory`, `multiSelections`, `createDirectory`
|
||||
and `showHiddenFiles`.
|
||||
* `callback` Function (optional)
|
||||
|
||||
On success this method returns an array of file paths chosen by the user,
|
||||
|
|
|
@ -24,8 +24,9 @@ Example on getting a real path from a dragged-onto-the-app file:
|
|||
};
|
||||
holder.ondrop = (e) => {
|
||||
e.preventDefault();
|
||||
const file = e.dataTransfer.files[0];
|
||||
console.log('File you dragged here is', file.path);
|
||||
for (let f of e.dataTransfer.files) {
|
||||
console.log('File(s) you dragged here: ', f.path);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# Possible Values of `app.getLocale()`
|
||||
# Locales
|
||||
|
||||
> Locale values returned by `app.getLocale()`.
|
||||
|
||||
Electron uses Chromium's `l10n_util` library to fetch the locale. Possible
|
||||
values are listed below:
|
|
@ -183,11 +183,11 @@ Menu.setApplicationMenu(menu);
|
|||
|
||||
Creates a new menu.
|
||||
|
||||
## Methods
|
||||
### Static Methods
|
||||
|
||||
The `menu` class has the following methods:
|
||||
The `menu` class has the following static methods:
|
||||
|
||||
### `Menu.setApplicationMenu(menu)`
|
||||
#### `Menu.setApplicationMenu(menu)`
|
||||
|
||||
* `menu` Menu
|
||||
|
||||
|
@ -196,11 +196,11 @@ will be set as each window's top menu.
|
|||
|
||||
**Note:** This API has to be called after the `ready` event of `app` module.
|
||||
|
||||
### `Menu.getApplicationMenu()`
|
||||
#### `Menu.getApplicationMenu()`
|
||||
|
||||
Returns the application menu (an instance of `Menu`), if set, or `null`, if not set.
|
||||
|
||||
### `Menu.sendActionToFirstResponder(action)` _macOS_
|
||||
#### `Menu.sendActionToFirstResponder(action)` _macOS_
|
||||
|
||||
* `action` String
|
||||
|
||||
|
@ -211,7 +211,7 @@ emulating default Cocoa menu behaviors, usually you would just use the
|
|||
See the [macOS Cocoa Event Handling Guide](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html#//apple_ref/doc/uid/10000060i-CH3-SW7)
|
||||
for more information on macOS' native actions.
|
||||
|
||||
### `Menu.buildFromTemplate(template)`
|
||||
#### `Menu.buildFromTemplate(template)`
|
||||
|
||||
* `template` Array
|
||||
|
||||
|
@ -221,11 +221,11 @@ Generally, the `template` is just an array of `options` for constructing a
|
|||
You can also attach other fields to the element of the `template` and they
|
||||
will become properties of the constructed menu items.
|
||||
|
||||
## Instance Methods
|
||||
### Instance Methods
|
||||
|
||||
The `menu` object has the following instance methods:
|
||||
|
||||
### `menu.popup([browserWindow, x, y, positioningItem])`
|
||||
#### `menu.popup([browserWindow, x, y, positioningItem])`
|
||||
|
||||
* `browserWindow` BrowserWindow (optional) - Default is `null`.
|
||||
* `x` Number (optional) - Default is -1.
|
||||
|
@ -238,35 +238,35 @@ Pops up this menu as a context menu in the `browserWindow`. You can optionally
|
|||
provide a `x, y` coordinate to place the menu at, otherwise it will be placed
|
||||
at the current mouse cursor position.
|
||||
|
||||
### `menu.append(menuItem)`
|
||||
#### `menu.append(menuItem)`
|
||||
|
||||
* `menuItem` MenuItem
|
||||
|
||||
Appends the `menuItem` to the menu.
|
||||
|
||||
### `menu.insert(pos, menuItem)`
|
||||
#### `menu.insert(pos, menuItem)`
|
||||
|
||||
* `pos` Integer
|
||||
* `menuItem` MenuItem
|
||||
|
||||
Inserts the `menuItem` to the `pos` position of the menu.
|
||||
|
||||
## Instance Properties
|
||||
### Instance Properties
|
||||
|
||||
`menu` objects also have the following properties:
|
||||
|
||||
### `menu.items`
|
||||
#### `menu.items`
|
||||
|
||||
Get an array containing the menu's items.
|
||||
|
||||
## Notes on macOS Application Menu
|
||||
|
||||
macOS has a completely different style of application menu from Windows and
|
||||
Linux, here are some notes on making your app's menu more native-like.
|
||||
Linux. Here are some notes on making your app's menu more native-like.
|
||||
|
||||
### Standard Menus
|
||||
|
||||
On macOS there are many system defined standard menus, like the `Services` and
|
||||
On macOS there are many system-defined standard menus, like the `Services` and
|
||||
`Windows` menus. To make your menu a standard menu, you should set your menu's
|
||||
`role` to one of following and Electron will recognize them and make them
|
||||
become standard menus:
|
||||
|
@ -283,15 +283,16 @@ action, you should set the `role` attribute of the menu item.
|
|||
|
||||
### Main Menu's Name
|
||||
|
||||
On macOS the label of application menu's first item is always your app's name,
|
||||
no matter what label you set. To change it you have to change your app's name
|
||||
by modifying your app bundle's `Info.plist` file. See [About Information
|
||||
Property List Files][AboutInformationPropertyListFiles] for more information.
|
||||
On macOS the label of the application menu's first item is always your app's
|
||||
name, no matter what label you set. To change it, modify your app bundle's
|
||||
`Info.plist` file. See
|
||||
[About Information Property List Files][AboutInformationPropertyListFiles]
|
||||
for more information.
|
||||
|
||||
## Setting Menu for Specific Browser Window (*Linux* *Windows*)
|
||||
|
||||
The [`setMenu` method][setMenu] of browser windows can set the menu of certain
|
||||
browser window.
|
||||
browser windows.
|
||||
|
||||
## Menu Item Position
|
||||
|
||||
|
|
|
@ -86,13 +86,13 @@ limit, whichever is lower for the current process.
|
|||
Returns an object giving memory usage statistics about the current process. Note
|
||||
that all statistics are reported in Kilobytes.
|
||||
|
||||
* `workingSetSize` - The amount of memory currently pinned to actual physical
|
||||
* `workingSetSize` Integer - The amount of memory currently pinned to actual physical
|
||||
RAM.
|
||||
* `peakWorkingSetSize` - The maximum amount of memory that has ever been pinned
|
||||
* `peakWorkingSetSize` Integer - The maximum amount of memory that has ever been pinned
|
||||
to actual physical RAM.
|
||||
* `privateBytes` - The amount of memory not shared by other processes, such as
|
||||
* `privateBytes` Integer - The amount of memory not shared by other processes, such as
|
||||
JS heap or HTML content.
|
||||
* `sharedBytes` - The amount of memory shared between processes, typically
|
||||
* `sharedBytes` Integer - The amount of memory shared between processes, typically
|
||||
memory consumed by the Electron code itself
|
||||
|
||||
### `process.getSystemMemoryInfo()`
|
||||
|
@ -100,14 +100,11 @@ that all statistics are reported in Kilobytes.
|
|||
Returns an object giving memory usage statistics about the entire system. Note
|
||||
that all statistics are reported in Kilobytes.
|
||||
|
||||
* `total` - The total amount of physical memory in Kilobytes available to the
|
||||
* `total` Integer - The total amount of physical memory in Kilobytes available to the
|
||||
system.
|
||||
* `free` - The total amount of memory not being used by applications or disk
|
||||
* `free` Integer - The total amount of memory not being used by applications or disk
|
||||
cache.
|
||||
|
||||
On Windows / Linux:
|
||||
|
||||
* `swapTotal` - The total amount of swap memory in Kilobytes available to the
|
||||
system.
|
||||
* `swapFree` - The free amount of swap memory in Kilobytes available to the
|
||||
system.
|
||||
* `swapTotal` Integer - The total amount of swap memory in Kilobytes available to the
|
||||
system. _Windows_ _Linux_
|
||||
* `swapFree` Integer - The free amount of swap memory in Kilobytes available to the
|
||||
system. _Windows_ _Linux_
|
||||
|
|
|
@ -21,7 +21,7 @@ win.loadURL('https://github.com');
|
|||
```
|
||||
|
||||
**Note:** for the reverse (access the renderer process from the main process),
|
||||
you can use [webContents.executeJavascript](web-contents.md#webcontentsexecutejavascriptcode-usergesture).
|
||||
you can use [webContents.executeJavascript](web-contents.md#webcontentsexecutejavascriptcode-usergesture-callback).
|
||||
|
||||
## Remote Objects
|
||||
|
||||
|
@ -74,7 +74,7 @@ exports.withRendererCallback = (mapper) => {
|
|||
};
|
||||
|
||||
exports.withLocalCallback = () => {
|
||||
return exports.mapNumbers(x => x + 1);
|
||||
return [1,2,3].map(x => x + 1);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -86,7 +86,7 @@ const withRendererCb = mapNumbers.withRendererCallback(x => x + 1);
|
|||
|
||||
const withLocalCb = mapNumbers.withLocalCallback();
|
||||
|
||||
console.log(withRendererCb, withLocalCb); // [true, true, true], [2, 3, 4]
|
||||
console.log(withRendererCb, withLocalCb); // [undefined, undefined, undefined], [2, 3, 4]
|
||||
```
|
||||
|
||||
As you can see, the renderer callback's synchronous return value was not as
|
||||
|
|
|
@ -20,17 +20,25 @@ const ses = win.webContents.session
|
|||
|
||||
The `session` module has the following methods:
|
||||
|
||||
### session.fromPartition(partition)
|
||||
### session.fromPartition(partition[, options])
|
||||
|
||||
* `partition` String
|
||||
* `options` Object
|
||||
* `cache` Boolean - Whether to enable cache.
|
||||
|
||||
Returns a new `Session` instance from `partition` string.
|
||||
Returns a `Session` instance from `partition` string. When there is an existing
|
||||
`Session` with the same `partition`, it will be returned; othewise a new
|
||||
`Session` instance will be created with `options`.
|
||||
|
||||
If `partition` starts with `persist:`, the page will use a persistent session
|
||||
available to all pages in the app with the same `partition`. if there is no
|
||||
`persist:` prefix, the page will use an in-memory session. If the `partition` is
|
||||
empty then default session of the app will be returned.
|
||||
|
||||
To create a `Session` with `options`, you have to ensure the `Session` with the
|
||||
`partition` has never been used before. There is no way to change the `options`
|
||||
of an existing `Session` object.
|
||||
|
||||
## Properties
|
||||
|
||||
The `session` module has the following properties:
|
||||
|
@ -90,7 +98,7 @@ Returns the session's current cache size.
|
|||
|
||||
Clears the session’s HTTP cache.
|
||||
|
||||
#### `ses.clearStorageData([options, ]callback)`
|
||||
#### `ses.clearStorageData([options, callback])`
|
||||
|
||||
* `options` Object (optional)
|
||||
* `origin` String - Should follow `window.location.origin`’s representation
|
||||
|
@ -100,7 +108,7 @@ Clears the session’s HTTP cache.
|
|||
`shadercache`, `websql`, `serviceworkers`
|
||||
* `quotas` Array - The types of quotas to clear, can contain:
|
||||
`temporary`, `persistent`, `syncable`.
|
||||
* `callback` Function - Called when operation is done.
|
||||
* `callback` Function (optional) - Called when operation is done.
|
||||
|
||||
Clears the data of web storages.
|
||||
|
||||
|
|
|
@ -122,6 +122,13 @@ Emitted when any dragged items are dropped on the tray icon.
|
|||
|
||||
Emitted when dragged files are dropped in the tray icon.
|
||||
|
||||
#### Event: 'drop-text' _macOS_
|
||||
|
||||
* `event` Event
|
||||
* `text` String - the dropped text string
|
||||
|
||||
Emitted when dragged text is dropped in the tray icon.
|
||||
|
||||
#### Event: 'drag-enter' _macOS_
|
||||
|
||||
Emitted when a drag operation enters the tray icon.
|
||||
|
|
|
@ -14,19 +14,37 @@ const {BrowserWindow} = require('electron');
|
|||
let win = new BrowserWindow({width: 800, height: 1500});
|
||||
win.loadURL('http://github.com');
|
||||
|
||||
let webContents = win.webContents;
|
||||
let contents = win.webContents;
|
||||
```
|
||||
|
||||
## Events
|
||||
## Methods
|
||||
|
||||
The `webContents` object emits the following events:
|
||||
These methods can be accessed from the `webContents` module:
|
||||
|
||||
### Event: 'did-finish-load'
|
||||
```js
|
||||
const {webContents} = require('electron');
|
||||
```
|
||||
|
||||
### `webContents.getAllWebContents()`
|
||||
|
||||
Returns an array of all web contents. This will contain web contents for all
|
||||
windows, webviews, opened devtools, and devtools extension background pages.
|
||||
|
||||
### `webContents.getFocusedWebContents()`
|
||||
|
||||
Returns the web contents that is focused in this application, otherwise
|
||||
returns `null`.
|
||||
|
||||
## Class: WebContents
|
||||
|
||||
### Instance Events
|
||||
|
||||
#### Event: 'did-finish-load'
|
||||
|
||||
Emitted when the navigation is done, i.e. the spinner of the tab has stopped
|
||||
spinning, and the `onload` event was dispatched.
|
||||
|
||||
### Event: 'did-fail-load'
|
||||
#### Event: 'did-fail-load'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -42,7 +60,7 @@ The full list of error codes and their meaning is available [here](https://code.
|
|||
Note that redirect responses will emit `errorCode` -3; you may want to ignore
|
||||
that error explicitly.
|
||||
|
||||
### Event: 'did-frame-finish-load'
|
||||
#### Event: 'did-frame-finish-load'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -51,15 +69,15 @@ Returns:
|
|||
|
||||
Emitted when a frame has done navigation.
|
||||
|
||||
### Event: 'did-start-loading'
|
||||
#### Event: 'did-start-loading'
|
||||
|
||||
Corresponds to the points in time when the spinner of the tab started spinning.
|
||||
|
||||
### Event: 'did-stop-loading'
|
||||
#### Event: 'did-stop-loading'
|
||||
|
||||
Corresponds to the points in time when the spinner of the tab stopped spinning.
|
||||
|
||||
### Event: 'did-get-response-details'
|
||||
#### Event: 'did-get-response-details'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -76,7 +94,7 @@ Returns:
|
|||
Emitted when details regarding a requested resource are available.
|
||||
`status` indicates the socket connection to download the resource.
|
||||
|
||||
### Event: 'did-get-redirect-request'
|
||||
#### Event: 'did-get-redirect-request'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -91,7 +109,7 @@ Returns:
|
|||
|
||||
Emitted when a redirect is received while requesting a resource.
|
||||
|
||||
### Event: 'dom-ready'
|
||||
#### Event: 'dom-ready'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -99,7 +117,7 @@ Returns:
|
|||
|
||||
Emitted when the document in the given frame is loaded.
|
||||
|
||||
### Event: 'page-favicon-updated'
|
||||
#### Event: 'page-favicon-updated'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -108,7 +126,7 @@ Returns:
|
|||
|
||||
Emitted when page receives favicon urls.
|
||||
|
||||
### Event: 'new-window'
|
||||
#### Event: 'new-window'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -127,7 +145,7 @@ By default a new `BrowserWindow` will be created for the `url`.
|
|||
|
||||
Calling `event.preventDefault()` will prevent creating new windows.
|
||||
|
||||
### Event: 'will-navigate'
|
||||
#### Event: 'will-navigate'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -146,7 +164,7 @@ this purpose.
|
|||
|
||||
Calling `event.preventDefault()` will prevent the navigation.
|
||||
|
||||
### Event: 'did-navigate'
|
||||
#### Event: 'did-navigate'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -159,7 +177,7 @@ This event is not emitted for in-page navigations, such as clicking anchor links
|
|||
or updating the `window.location.hash`. Use `did-navigate-in-page` event for
|
||||
this purpose.
|
||||
|
||||
### Event: 'did-navigate-in-page'
|
||||
#### Event: 'did-navigate-in-page'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -172,11 +190,11 @@ When in-page navigation happens, the page URL changes but does not cause
|
|||
navigation outside of the page. Examples of this occurring are when anchor links
|
||||
are clicked or when the DOM `hashchange` event is triggered.
|
||||
|
||||
### Event: 'crashed'
|
||||
#### Event: 'crashed'
|
||||
|
||||
Emitted when the renderer process has crashed.
|
||||
|
||||
### Event: 'plugin-crashed'
|
||||
#### Event: 'plugin-crashed'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -186,23 +204,23 @@ Returns:
|
|||
|
||||
Emitted when a plugin process has crashed.
|
||||
|
||||
### Event: 'destroyed'
|
||||
#### Event: 'destroyed'
|
||||
|
||||
Emitted when `webContents` is destroyed.
|
||||
|
||||
### Event: 'devtools-opened'
|
||||
#### Event: 'devtools-opened'
|
||||
|
||||
Emitted when DevTools is opened.
|
||||
|
||||
### Event: 'devtools-closed'
|
||||
#### Event: 'devtools-closed'
|
||||
|
||||
Emitted when DevTools is closed.
|
||||
|
||||
### Event: 'devtools-focused'
|
||||
#### Event: 'devtools-focused'
|
||||
|
||||
Emitted when DevTools is focused / opened.
|
||||
|
||||
### Event: 'certificate-error'
|
||||
#### Event: 'certificate-error'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -211,7 +229,12 @@ Returns:
|
|||
* `error` String - The error code
|
||||
* `certificate` Object
|
||||
* `data` Buffer - PEM encoded data
|
||||
* `issuerName` String
|
||||
* `issuerName` String - Issuer's Common Name
|
||||
* `subjectName` String - Subject's Common Name
|
||||
* `serialNumber` String - Hex value represented string
|
||||
* `validStart` Integer - Start date of the certificate being valid in seconds
|
||||
* `validExpiry` Integer - End date of the certificate being valid in seconds
|
||||
* `fingerprint` String - Fingerprint of the certificate
|
||||
* `callback` Function
|
||||
|
||||
Emitted when failed to verify the `certificate` for `url`.
|
||||
|
@ -219,7 +242,7 @@ Emitted when failed to verify the `certificate` for `url`.
|
|||
The usage is the same with [the `certificate-error` event of
|
||||
`app`](app.md#event-certificate-error).
|
||||
|
||||
### Event: 'select-client-certificate'
|
||||
#### Event: 'select-client-certificate'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -228,6 +251,11 @@ Returns:
|
|||
* `certificateList` [Objects]
|
||||
* `data` Buffer - PEM encoded data
|
||||
* `issuerName` String - Issuer's Common Name
|
||||
* `subjectName` String - Subject's Common Name
|
||||
* `serialNumber` String - Hex value represented string
|
||||
* `validStart` Integer - Start date of the certificate being valid in seconds
|
||||
* `validExpiry` Integer - End date of the certificate being valid in seconds
|
||||
* `fingerprint` String - Fingerprint of the certificate
|
||||
* `callback` Function
|
||||
|
||||
Emitted when a client certificate is requested.
|
||||
|
@ -235,7 +263,7 @@ Emitted when a client certificate is requested.
|
|||
The usage is the same with [the `select-client-certificate` event of
|
||||
`app`](app.md#event-select-client-certificate).
|
||||
|
||||
### Event: 'login'
|
||||
#### Event: 'login'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -256,7 +284,7 @@ Emitted when `webContents` wants to do basic auth.
|
|||
|
||||
The usage is the same with [the `login` event of `app`](app.md#event-login).
|
||||
|
||||
### Event: 'found-in-page'
|
||||
#### Event: 'found-in-page'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -271,15 +299,15 @@ Returns:
|
|||
Emitted when a result is available for
|
||||
[`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request.
|
||||
|
||||
### Event: 'media-started-playing'
|
||||
#### Event: 'media-started-playing'
|
||||
|
||||
Emitted when media starts playing.
|
||||
|
||||
### Event: 'media-paused'
|
||||
#### Event: 'media-paused'
|
||||
|
||||
Emitted when media is paused or done playing.
|
||||
|
||||
### Event: 'did-change-theme-color'
|
||||
#### Event: 'did-change-theme-color'
|
||||
|
||||
Emitted when a page's theme color changes. This is usually due to encountering
|
||||
a meta tag:
|
||||
|
@ -288,7 +316,7 @@ a meta tag:
|
|||
<meta name='theme-color' content='#ff0000'>
|
||||
```
|
||||
|
||||
### Event: 'update-target-url'
|
||||
#### Event: 'update-target-url'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -297,7 +325,7 @@ Returns:
|
|||
|
||||
Emitted when mouse moves over a link or the keyboard moves the focus to a link.
|
||||
|
||||
### Event: 'cursor-changed'
|
||||
#### Event: 'cursor-changed'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -319,7 +347,7 @@ If the `type` parameter is `custom`, the `image` parameter will hold the custom
|
|||
cursor image in a `NativeImage`, and the `scale` will hold scaling information
|
||||
for the image.
|
||||
|
||||
### Event: 'context-menu'
|
||||
#### Event: 'context-menu'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -384,7 +412,7 @@ The `editFlags` is an object with the following properties:
|
|||
|
||||
Emitted when there is a new context menu that needs to be handled.
|
||||
|
||||
### Event: 'select-bluetooth-device'
|
||||
#### Event: 'select-bluetooth-device'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -420,11 +448,9 @@ app.on('ready', () => {
|
|||
})
|
||||
```
|
||||
|
||||
## Instance Methods
|
||||
### Instance Methods
|
||||
|
||||
The `webContents` object has the following instance methods:
|
||||
|
||||
### `webContents.loadURL(url[, options])`
|
||||
#### `contents.loadURL(url[, options])`
|
||||
|
||||
* `url` URL
|
||||
* `options` Object (optional)
|
||||
|
@ -441,14 +467,14 @@ const options = {extraHeaders: 'pragma: no-cache\n'};
|
|||
webContents.loadURL(url, options);
|
||||
```
|
||||
|
||||
### `webContents.downloadURL(url)`
|
||||
#### `contents.downloadURL(url)`
|
||||
|
||||
* `url` URL
|
||||
|
||||
Initiates a download of the resource at `url` without navigating. The
|
||||
`will-download` event of `session` will be triggered.
|
||||
|
||||
### `webContents.getURL()`
|
||||
#### `contents.getURL()`
|
||||
|
||||
Returns URL of the current web page.
|
||||
|
||||
|
@ -459,95 +485,99 @@ win.loadURL('http://github.com');
|
|||
let currentURL = win.webContents.getURL();
|
||||
```
|
||||
|
||||
### `webContents.getTitle()`
|
||||
#### `contents.getTitle()`
|
||||
|
||||
Returns the title of the current web page.
|
||||
|
||||
### `webContents.isLoading()`
|
||||
#### `contents.isFocused()`
|
||||
|
||||
Returns a Boolean, whether the web page is focused.
|
||||
|
||||
#### `contents.isLoading()`
|
||||
|
||||
Returns whether web page is still loading resources.
|
||||
|
||||
### `webContents.isLoadingMainFrame()`
|
||||
#### `contents.isLoadingMainFrame()`
|
||||
|
||||
Returns whether the main frame (and not just iframes or frames within it) is
|
||||
still loading.
|
||||
|
||||
### `webContents.isWaitingForResponse()`
|
||||
#### `contents.isWaitingForResponse()`
|
||||
|
||||
Returns whether the web page is waiting for a first-response from the main
|
||||
resource of the page.
|
||||
|
||||
### `webContents.stop()`
|
||||
#### `contents.stop()`
|
||||
|
||||
Stops any pending navigation.
|
||||
|
||||
### `webContents.reload()`
|
||||
#### `contents.reload()`
|
||||
|
||||
Reloads the current web page.
|
||||
|
||||
### `webContents.reloadIgnoringCache()`
|
||||
#### `contents.reloadIgnoringCache()`
|
||||
|
||||
Reloads current page and ignores cache.
|
||||
|
||||
### `webContents.canGoBack()`
|
||||
#### `contents.canGoBack()`
|
||||
|
||||
Returns whether the browser can go back to previous web page.
|
||||
|
||||
### `webContents.canGoForward()`
|
||||
#### `contents.canGoForward()`
|
||||
|
||||
Returns whether the browser can go forward to next web page.
|
||||
|
||||
### `webContents.canGoToOffset(offset)`
|
||||
#### `contents.canGoToOffset(offset)`
|
||||
|
||||
* `offset` Integer
|
||||
|
||||
Returns whether the web page can go to `offset`.
|
||||
|
||||
### `webContents.clearHistory()`
|
||||
#### `contents.clearHistory()`
|
||||
|
||||
Clears the navigation history.
|
||||
|
||||
### `webContents.goBack()`
|
||||
#### `contents.goBack()`
|
||||
|
||||
Makes the browser go back a web page.
|
||||
|
||||
### `webContents.goForward()`
|
||||
#### `contents.goForward()`
|
||||
|
||||
Makes the browser go forward a web page.
|
||||
|
||||
### `webContents.goToIndex(index)`
|
||||
#### `contents.goToIndex(index)`
|
||||
|
||||
* `index` Integer
|
||||
|
||||
Navigates browser to the specified absolute web page index.
|
||||
|
||||
### `webContents.goToOffset(offset)`
|
||||
#### `contents.goToOffset(offset)`
|
||||
|
||||
* `offset` Integer
|
||||
|
||||
Navigates to the specified offset from the "current entry".
|
||||
|
||||
### `webContents.isCrashed()`
|
||||
#### `contents.isCrashed()`
|
||||
|
||||
Whether the renderer process has crashed.
|
||||
|
||||
### `webContents.setUserAgent(userAgent)`
|
||||
#### `contents.setUserAgent(userAgent)`
|
||||
|
||||
* `userAgent` String
|
||||
|
||||
Overrides the user agent for this web page.
|
||||
|
||||
### `webContents.getUserAgent()`
|
||||
#### `contents.getUserAgent()`
|
||||
|
||||
Returns a `String` representing the user agent for this web page.
|
||||
|
||||
### `webContents.insertCSS(css)`
|
||||
#### `contents.insertCSS(css)`
|
||||
|
||||
* `css` String
|
||||
|
||||
Injects CSS into the current web page.
|
||||
|
||||
### `webContents.executeJavaScript(code[, userGesture, callback])`
|
||||
#### `contents.executeJavaScript(code[, userGesture, callback])`
|
||||
|
||||
* `code` String
|
||||
* `userGesture` Boolean (optional)
|
||||
|
@ -560,71 +590,71 @@ In the browser window some HTML APIs like `requestFullScreen` can only be
|
|||
invoked by a gesture from the user. Setting `userGesture` to `true` will remove
|
||||
this limitation.
|
||||
|
||||
### `webContents.setAudioMuted(muted)`
|
||||
#### `contents.setAudioMuted(muted)`
|
||||
|
||||
* `muted` Boolean
|
||||
|
||||
Mute the audio on the current web page.
|
||||
|
||||
### `webContents.isAudioMuted()`
|
||||
#### `contents.isAudioMuted()`
|
||||
|
||||
Returns whether this page has been muted.
|
||||
|
||||
### `webContents.undo()`
|
||||
#### `contents.undo()`
|
||||
|
||||
Executes the editing command `undo` in web page.
|
||||
|
||||
### `webContents.redo()`
|
||||
#### `contents.redo()`
|
||||
|
||||
Executes the editing command `redo` in web page.
|
||||
|
||||
### `webContents.cut()`
|
||||
#### `contents.cut()`
|
||||
|
||||
Executes the editing command `cut` in web page.
|
||||
|
||||
### `webContents.copy()`
|
||||
#### `contents.copy()`
|
||||
|
||||
Executes the editing command `copy` in web page.
|
||||
|
||||
### `webContents.paste()`
|
||||
#### `contents.paste()`
|
||||
|
||||
Executes the editing command `paste` in web page.
|
||||
|
||||
### `webContents.pasteAndMatchStyle()`
|
||||
#### `contents.pasteAndMatchStyle()`
|
||||
|
||||
Executes the editing command `pasteAndMatchStyle` in web page.
|
||||
|
||||
### `webContents.delete()`
|
||||
#### `contents.delete()`
|
||||
|
||||
Executes the editing command `delete` in web page.
|
||||
|
||||
### `webContents.selectAll()`
|
||||
#### `contents.selectAll()`
|
||||
|
||||
Executes the editing command `selectAll` in web page.
|
||||
|
||||
### `webContents.unselect()`
|
||||
#### `contents.unselect()`
|
||||
|
||||
Executes the editing command `unselect` in web page.
|
||||
|
||||
### `webContents.replace(text)`
|
||||
#### `contents.replace(text)`
|
||||
|
||||
* `text` String
|
||||
|
||||
Executes the editing command `replace` in web page.
|
||||
|
||||
### `webContents.replaceMisspelling(text)`
|
||||
#### `contents.replaceMisspelling(text)`
|
||||
|
||||
* `text` String
|
||||
|
||||
Executes the editing command `replaceMisspelling` in web page.
|
||||
|
||||
### `webContents.insertText(text)`
|
||||
#### `contents.insertText(text)`
|
||||
|
||||
* `text` String
|
||||
|
||||
Inserts `text` to the focused element.
|
||||
|
||||
### `webContents.findInPage(text[, options])`
|
||||
#### `contents.findInPage(text[, options])`
|
||||
|
||||
* `text` String - Content to be searched, must not be empty.
|
||||
* `options` Object (optional)
|
||||
|
@ -645,12 +675,12 @@ an `Integer` representing the request id used for the request. The result of
|
|||
the request can be obtained by subscribing to
|
||||
[`found-in-page`](web-contents.md#event-found-in-page) event.
|
||||
|
||||
### `webContents.stopFindInPage(action)`
|
||||
#### `contents.stopFindInPage(action)`
|
||||
|
||||
* `action` String - Specifies the action to take place when ending
|
||||
[`webContents.findInPage`](web-contents.md#webcontentfindinpage) request.
|
||||
* `clearSelection` - Translate the selection into a normal selection.
|
||||
* `keepSelection` - Clear the selection.
|
||||
* `clearSelection` - Clear the selection.
|
||||
* `keepSelection` - Translate the selection into a normal selection.
|
||||
* `activateSelection` - Focus and click the selection node.
|
||||
|
||||
Stops any `findInPage` request for the `webContents` with the provided `action`.
|
||||
|
@ -664,14 +694,28 @@ webContents.on('found-in-page', (event, result) => {
|
|||
const requestId = webContents.findInPage('api');
|
||||
```
|
||||
|
||||
### `webContents.hasServiceWorker(callback)`
|
||||
#### `contents.capturePage([rect, ]callback)`
|
||||
|
||||
* `rect` Object (optional) - The area of the page to be captured
|
||||
* `x` Integer
|
||||
* `y` Integer
|
||||
* `width` Integer
|
||||
* `height` Integer
|
||||
* `callback` Function
|
||||
|
||||
Captures a snapshot of the page within `rect`. Upon completion `callback` will
|
||||
be called with `callback(image)`. The `image` is an instance of
|
||||
[NativeImage](native-image.md) that stores data of the snapshot. Omitting
|
||||
`rect` will capture the whole visible page.
|
||||
|
||||
#### `contents.hasServiceWorker(callback)`
|
||||
|
||||
* `callback` Function
|
||||
|
||||
Checks if any ServiceWorker is registered and returns a boolean as
|
||||
response to `callback`.
|
||||
|
||||
### `webContents.unregisterServiceWorker(callback)`
|
||||
#### `contents.unregisterServiceWorker(callback)`
|
||||
|
||||
* `callback` Function
|
||||
|
||||
|
@ -679,24 +723,20 @@ Unregisters any ServiceWorker if present and returns a boolean as
|
|||
response to `callback` when the JS promise is fulfilled or false
|
||||
when the JS promise is rejected.
|
||||
|
||||
### `webContents.print([options])`
|
||||
#### `contents.print([options])`
|
||||
|
||||
* `options` Object (optional)
|
||||
* `silent` Boolean - Don't ask user for print settings. Default is `false`.
|
||||
* `printBackground` Boolean - Also prints the background color and image of
|
||||
the web page. Default is `false`.
|
||||
|
||||
Prints window's web page. When `silent` is set to `false`, Electron will pick
|
||||
Prints window's web page. When `silent` is set to `true`, Electron will pick
|
||||
up system's default printer and default settings for printing.
|
||||
|
||||
Calling `window.print()` in web page is equivalent to calling
|
||||
`webContents.print({silent: false, printBackground: false})`.
|
||||
|
||||
**Note:** On Windows, the print API relies on `pdf.dll`. If your application
|
||||
doesn't need the print feature, you can safely remove `pdf.dll` to reduce binary
|
||||
size.
|
||||
|
||||
### `webContents.printToPDF(options, callback)`
|
||||
#### `contents.printToPDF(options, callback)`
|
||||
|
||||
* `options` Object
|
||||
* `marginsType` Integer - Specifies the type of margins to use. Uses 0 for
|
||||
|
@ -748,7 +788,7 @@ win.webContents.on('did-finish-load', () => {
|
|||
});
|
||||
```
|
||||
|
||||
### `webContents.addWorkSpace(path)`
|
||||
#### `contents.addWorkSpace(path)`
|
||||
|
||||
* `path` String
|
||||
|
||||
|
@ -761,13 +801,13 @@ win.webContents.on('devtools-opened', () => {
|
|||
});
|
||||
```
|
||||
|
||||
### `webContents.removeWorkSpace(path)`
|
||||
#### `contents.removeWorkSpace(path)`
|
||||
|
||||
* `path` String
|
||||
|
||||
Removes the specified path from DevTools workspace.
|
||||
|
||||
### `webContents.openDevTools([options])`
|
||||
#### `contents.openDevTools([options])`
|
||||
|
||||
* `options` Object (optional)
|
||||
* `mode` String - Opens the devtools with specified dock state, can be
|
||||
|
@ -776,34 +816,34 @@ Removes the specified path from DevTools workspace.
|
|||
|
||||
Opens the devtools.
|
||||
|
||||
### `webContents.closeDevTools()`
|
||||
#### `contents.closeDevTools()`
|
||||
|
||||
Closes the devtools.
|
||||
|
||||
### `webContents.isDevToolsOpened()`
|
||||
#### `contents.isDevToolsOpened()`
|
||||
|
||||
Returns whether the devtools is opened.
|
||||
|
||||
### `webContents.isDevToolsFocused()`
|
||||
#### `contents.isDevToolsFocused()`
|
||||
|
||||
Returns whether the devtools view is focused .
|
||||
|
||||
### `webContents.toggleDevTools()`
|
||||
#### `contents.toggleDevTools()`
|
||||
|
||||
Toggles the developer tools.
|
||||
|
||||
### `webContents.inspectElement(x, y)`
|
||||
#### `contents.inspectElement(x, y)`
|
||||
|
||||
* `x` Integer
|
||||
* `y` Integer
|
||||
|
||||
Starts inspecting element at position (`x`, `y`).
|
||||
|
||||
### `webContents.inspectServiceWorker()`
|
||||
#### `contents.inspectServiceWorker()`
|
||||
|
||||
Opens the developer tools for the service worker context.
|
||||
|
||||
### `webContents.send(channel[, arg1][, arg2][, ...])`
|
||||
#### `contents.send(channel[, arg1][, arg2][, ...])`
|
||||
|
||||
* `channel` String
|
||||
* `arg` (optional)
|
||||
|
@ -843,7 +883,7 @@ app.on('ready', () => {
|
|||
</html>
|
||||
```
|
||||
|
||||
### `webContents.enableDeviceEmulation(parameters)`
|
||||
#### `contents.enableDeviceEmulation(parameters)`
|
||||
|
||||
`parameters` Object, properties:
|
||||
|
||||
|
@ -874,11 +914,11 @@ app.on('ready', () => {
|
|||
|
||||
Enable device emulation with the given parameters.
|
||||
|
||||
### `webContents.disableDeviceEmulation()`
|
||||
#### `contents.disableDeviceEmulation()`
|
||||
|
||||
Disable device emulation enabled by `webContents.enableDeviceEmulation`.
|
||||
|
||||
### `webContents.sendInputEvent(event)`
|
||||
#### `contents.sendInputEvent(event)`
|
||||
|
||||
* `event` Object
|
||||
* `type` String (**required**) - The type of the event, can be `mouseDown`,
|
||||
|
@ -919,7 +959,7 @@ For the `mouseWheel` event, the `event` object also have following properties:
|
|||
* `hasPreciseScrollingDeltas` Boolean
|
||||
* `canScroll` Boolean
|
||||
|
||||
### `webContents.beginFrameSubscription([onlyDirty ,]callback)`
|
||||
#### `contents.beginFrameSubscription([onlyDirty ,]callback)`
|
||||
|
||||
* `onlyDirty` Boolean (optional) - Defaults to `false`
|
||||
* `callback` Function
|
||||
|
@ -939,11 +979,11 @@ describes which part of the page was repainted. If `onlyDirty` is set to
|
|||
`true`, `frameBuffer` will only contain the repainted area. `onlyDirty`
|
||||
defaults to `false`.
|
||||
|
||||
### `webContents.endFrameSubscription()`
|
||||
#### `contents.endFrameSubscription()`
|
||||
|
||||
End subscribing for frame presentation events.
|
||||
|
||||
### `webContents.startDrag(item)`
|
||||
#### `contents.startDrag(item)`
|
||||
|
||||
* `item` object
|
||||
* `file` String
|
||||
|
@ -953,7 +993,7 @@ Sets the `item` as dragging item for current drag-drop operation, `file` is the
|
|||
absolute path of the file to be dragged, and `icon` is the image showing under
|
||||
the cursor when dragging.
|
||||
|
||||
### `webContents.savePage(fullPath, saveType, callback)`
|
||||
#### `contents.savePage(fullPath, saveType, callback)`
|
||||
|
||||
* `fullPath` String - The full file path.
|
||||
* `saveType` String - Specify the save type.
|
||||
|
@ -976,34 +1016,36 @@ win.webContents.on('did-finish-load', () => {
|
|||
});
|
||||
```
|
||||
|
||||
### `webContents.showDefinitionForSelection()` _macOS_
|
||||
#### `contents.showDefinitionForSelection()` _macOS_
|
||||
|
||||
Shows pop-up dictionary that searches the selected word on the page.
|
||||
|
||||
## Instance Properties
|
||||
### Instance Properties
|
||||
|
||||
`WebContents` objects also have the following properties:
|
||||
|
||||
### `webContents.id`
|
||||
#### `contents.id`
|
||||
|
||||
The unique ID of this WebContents.
|
||||
|
||||
### `webContents.session`
|
||||
#### `contents.session`
|
||||
|
||||
Returns the [session](session.md) object used by this webContents.
|
||||
|
||||
### `webContents.hostWebContents`
|
||||
#### `contents.hostWebContents`
|
||||
|
||||
Returns the `WebContents` that might own this `WebContents`.
|
||||
|
||||
### `webContents.devToolsWebContents`
|
||||
#### `contents.devToolsWebContents`
|
||||
|
||||
Get the `WebContents` of DevTools for this `WebContents`.
|
||||
|
||||
**Note:** Users should never store this object because it may become `null`
|
||||
when the DevTools has been closed.
|
||||
|
||||
### `webContents.debugger`
|
||||
#### `contents.debugger`
|
||||
|
||||
Get the debugger instance for this webContents.
|
||||
|
||||
## Class: Debugger
|
||||
|
||||
Debugger API serves as an alternate transport for [remote debugging protocol][rdp].
|
||||
|
||||
|
@ -1028,21 +1070,23 @@ win.webContents.debugger.on('message', (event, method, params) => {
|
|||
win.webContents.debugger.sendCommand('Network.enable');
|
||||
```
|
||||
|
||||
#### `webContents.debugger.attach([protocolVersion])`
|
||||
### Instance Methods
|
||||
|
||||
#### `debugger.attach([protocolVersion])`
|
||||
|
||||
* `protocolVersion` String (optional) - Requested debugging protocol version.
|
||||
|
||||
Attaches the debugger to the `webContents`.
|
||||
|
||||
#### `webContents.debugger.isAttached()`
|
||||
#### `debugger.isAttached()`
|
||||
|
||||
Returns a boolean indicating whether a debugger is attached to the `webContents`.
|
||||
|
||||
#### `webContents.debugger.detach()`
|
||||
#### `debugger.detach()`
|
||||
|
||||
Detaches the debugger from the `webContents`.
|
||||
|
||||
#### `webContents.debugger.sendCommand(method[, commandParams, callback])`
|
||||
#### `debugger.sendCommand(method[, commandParams, callback])`
|
||||
|
||||
* `method` String - Method name, should be one of the methods defined by the
|
||||
remote debugging protocol.
|
||||
|
@ -1054,6 +1098,8 @@ Detaches the debugger from the `webContents`.
|
|||
|
||||
Send given command to the debugging target.
|
||||
|
||||
### Instance Events
|
||||
|
||||
#### Event: 'detach'
|
||||
|
||||
* `event` Event
|
||||
|
|
|
@ -121,9 +121,6 @@ than the minimum values or greater than the maximum.
|
|||
If "on", the guest page in `webview` will have node integration and can use node
|
||||
APIs like `require` and `process` to access low level system resources.
|
||||
|
||||
**Note:** Node integration will always be disabled in the `webview` if it is
|
||||
disabled on the parent window.
|
||||
|
||||
### `plugins`
|
||||
|
||||
```html
|
||||
|
@ -463,11 +460,15 @@ Stops any `findInPage` request for the `webview` with the provided `action`.
|
|||
|
||||
### `<webview>.print([options])`
|
||||
|
||||
Prints `webview`'s web page. Same with `webContents.print([options])`.
|
||||
Prints `webview`'s web page. Same as `webContents.print([options])`.
|
||||
|
||||
### `<webview>.printToPDF(options, callback)`
|
||||
|
||||
Prints `webview`'s web page as PDF, Same with `webContents.printToPDF(options, callback)`
|
||||
Prints `webview`'s web page as PDF, Same as `webContents.printToPDF(options, callback)`.
|
||||
|
||||
### `<webview>.capturePage([rect, ]callback)`
|
||||
|
||||
Captures a snapshot of the `webview`'s page. Same as `webContents.capturePage([rect, ]callback)`.
|
||||
|
||||
### `<webview>.send(channel[, arg1][, arg2][, ...])`
|
||||
|
||||
|
@ -487,7 +488,7 @@ examples.
|
|||
|
||||
Sends an input `event` to the page.
|
||||
|
||||
See [webContents.sendInputEvent](web-contents.md##webcontentssendinputeventevent)
|
||||
See [webContents.sendInputEvent](web-contents.md#webcontentssendinputeventevent)
|
||||
for detailed description of `event` object.
|
||||
|
||||
### `<webview>.showDefinitionForSelection()` _macOS_
|
||||
|
|
|
@ -41,33 +41,37 @@ origin preference.
|
|||
The `BrowserWindowProxy` object is returned from `window.open` and provides
|
||||
limited functionality with the child window.
|
||||
|
||||
### `BrowserWindowProxy.blur()`
|
||||
### Instance Methods
|
||||
|
||||
The `BrowserWindowProxy` object has the following instance methods:
|
||||
|
||||
#### `BrowserWindowProxy.blur()`
|
||||
|
||||
Removes focus from the child window.
|
||||
|
||||
### `BrowserWindowProxy.close()`
|
||||
#### `BrowserWindowProxy.close()`
|
||||
|
||||
Forcefully closes the child window without calling its unload event.
|
||||
|
||||
### `BrowserWindowProxy.closed`
|
||||
#### `BrowserWindowProxy.closed`
|
||||
|
||||
Set to true after the child window gets closed.
|
||||
|
||||
### `BrowserWindowProxy.eval(code)`
|
||||
#### `BrowserWindowProxy.eval(code)`
|
||||
|
||||
* `code` String
|
||||
|
||||
Evaluates the code in the child window.
|
||||
|
||||
### `BrowserWindowProxy.focus()`
|
||||
#### `BrowserWindowProxy.focus()`
|
||||
|
||||
Focuses the child window (brings the window to front).
|
||||
|
||||
### `BrowserWindowProxy.print()`
|
||||
#### `BrowserWindowProxy.print()`
|
||||
|
||||
Invokes the print dialog on the child window.
|
||||
|
||||
### `BrowserWindowProxy.postMessage(message, targetOrigin)`
|
||||
#### `BrowserWindowProxy.postMessage(message, targetOrigin)`
|
||||
|
||||
* `message` String
|
||||
* `targetOrigin` String
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue