Skip to content

Commit

Permalink
docs: Documentation fixes for loadURL and loadUrlOptions (#330)
Browse files Browse the repository at this point in the history
* Correction for loadURL API.

Save the next guy like an hour or something. :) https://stackoverflow.com/a/37614774

* Update types.ts

Also update references to `loadURL` in typedefs.

* Update README.md

Add missing options to README for loadUrlOptions
  • Loading branch information
tgxn authored Apr 29, 2021
1 parent 09240c8 commit c7d6640
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ You can pass an optional options object into the `menubar({ ... })` function:
- `tooltip` (default empty) - menubar tray icon tooltip text
- `tray` (default created on-the-fly) - an electron `Tray` instance. if provided `opts.icon` will be ignored
- `preloadWindow` (default false) - Create [BrowserWindow](https://electronjs.org/docs/api/browser-window#new-browserwindowoptions) instance before it is used -- increasing resource usage, but making the click on the menubar load faster.
- `loadUrlOptions` - (default undefined) The options passed when loading the index URL in the menubar's browserWindow. Everything browserWindow.loadURL supports is supported; this object is simply passed onto [browserWindow.loadURL](https://electronjs.org/docs/api/browser-window#winloadurlurl-options)
- `showOnAllWorkspaces` (default true) - Makes the window available on all OS X workspaces.
- `windowPosition` (default trayCenter and trayBottomCenter on Windows) - Sets the window position (x and y will still override this), check [positioner docs](https://github.com/jenslind/electron-positioner#docs) for valid values.
- `showDockIcon` (default false) - Configure the visibility of the application dock icon.
Expand Down Expand Up @@ -128,7 +129,7 @@ See the reference [API docs](./docs/globals.md).

## Tips

- Use `mb.on('after-create-window', callback)` to run things after your app has loaded. For example you could run `mb.window.openDevTools()` to open the developer tools for debugging, or load a different URL with `mb.window.loadUrl()`
- Use `mb.on('after-create-window', callback)` to run things after your app has loaded. For example you could run `mb.window.openDevTools()` to open the developer tools for debugging, or load a different URL with `mb.window.loadURL()`
- Use `mb.on('focus-lost')` if you would like to perform some operation when using the option `browserWindow.alwaysOnTop: true`
- To restore focus of previous window after menubar hide, use `mb.on('after-hide', () => { mb.app.hide() } )` or similar
- To create a native menu, you can use `tray.setContextMenu(contextMenu)`, and pass this custom tray to menubar: `const mb = menubar({ tray });`. See [this example](https://github.com/maxogden/menubar/tree/master/examples/native-menu) for more information.
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ export interface Options {
/**
* The URL to load the menubar's browserWindow with. The url can be a remote
* address (e.g. `http://`) or a path to a local HTML file using the
* `file://` protocol. If false, then menubar won't call `loadUrl` on
* `file://` protocol. If false, then menubar won't call `loadURL` on
* start.
* @default `file:// + options.dir + index.html`
* @see https://electronjs.org/docs/api/browser-window#winloadurlurl-options
*/
index: string | false;
/**
* The options passed when loading the index URL in the menubar's
* browserWindow. Everything browserWindow.loadUrl supports is supported;
* this object is simply passed onto browserWindow.loadUrl
* browserWindow. Everything browserWindow.loadURL supports is supported;
* this object is simply passed onto browserWindow.loadURL
* @default `{}`
* @see https://electronjs.org/docs/api/browser-window#winloadurlurl-options
*/
Expand Down

0 comments on commit c7d6640

Please sign in to comment.