electron js убрать меню

Electron js убрать меню

Create native application menus and context menus.

new Menu() ​

Creates a new menu.

Static Methods​

The Menu class has the following static methods:

Menu.setApplicationMenu(menu) ​

Sets menu as the application menu on macOS. On Windows and Linux, the menu will be set as each window’s top menu.

Also on Windows and Linux, you can use a & in the top-level item name to indicate which letter should get a generated accelerator. For example, using &File for the file menu would result in a generated Alt-F accelerator that opens the associated menu. The indicated character in the button label then gets an underline, and the & character is not displayed on the button label.

Passing null will suppress the default menu. On Windows and Linux, this has the additional effect of removing the menu bar from the window.

Menu.getApplicationMenu() ​

Note: The returned Menu instance doesn’t support dynamic addition or removal of menu items. Instance properties can still be dynamically modified.

Menu.sendActionToFirstResponder(action) macOS​

See the macOS Cocoa Event Handling Guide for more information on macOS’ native actions.

Menu.buildFromTemplate(template) ​

Generally, the template is an array of options for constructing a MenuItem. The usage can be referenced above.

You can also attach other fields to the element of the template and they will become properties of the constructed menu items.

Instance Methods​

The menu object has the following instance methods:

menu.popup([options]) ​

menu.closePopup([browserWindow]) ​

menu.append(menuItem) ​

Appends the menuItem to the menu.

menu.getMenuItemById(id) ​

Returns MenuItem | null the item with the specified id

menu.insert(pos, menuItem) ​

Inserts the menuItem to the pos position of the menu.

Instance Events​

Objects created with new Menu or returned by Menu.buildFromTemplate emit the following events:

Note: Some events are only available on specific operating systems and are labeled as such.

Event: ‘menu-will-show’​

Emitted when menu.popup() is called.

Event: ‘menu-will-close’​

Instance Properties​

menu objects also have the following properties:

menu.items ​

A MenuItem[] array containing the menu’s items.

Each Menu consists of multiple MenuItem s and each MenuItem can have a submenu.

Examples​

An example of creating the application menu with the simple template API:

Render process​

To create menus initiated by the renderer process, send the required information to the main process using IPC and have the main process display the menu on behalf of the renderer.

Below is an example of showing a menu when the user right clicks the page:

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.

Standard Menus​

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 the following and Electron will recognize them and make them become standard menus:

Standard Menu Item Actions​

Main Menu’s Name​

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 for more information.

Setting Menu for Specific Browser Window ( Linux Windows)​

The setMenu method of browser windows can set the menu of certain browser windows.

Menu Item Position​

By default, items will be inserted in the order they exist in the template unless one of the specified positioning keywords is used.

Источник

Remove menubar from Electron app

How do I remove this menu-bar from my electron apps:

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

Also it says «Hello World»(is this because I downloaded electron pre-built, and will go away once I package the application?). I didn’t code these into the html, so I don’t know how to get it out!-

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

16 Answers 16

You can use w.setMenu(null) or set frame: false (this also removes buttons for close, minimize and maximize options) on your window. See setMenu() or BrowserWindow(). Also check this thread

In new versions of Electron, you can set autoHideMenuBar: true while creating browserWindow, pressing Alt will show the menu bar again.

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

For Electron 7.1.1, you can use this:

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

Relevant methods:

There is also the method for making a frameless window as shown bellow:

(no close button no anything. Can be what we want (better design))

Edit: (new)

win.removeMenu() Linux Windows Remove the window’s menu bar.

Added win.removeMenu() to remove application menus instead of using win.setMenu(null)

That is added from v5 as per:

Electron v7 bug

For Electron 7.1.1 use Menu.setApplicationMenu instead of win.removeMenu()

And the big note is: you have to call it before creating the BrowserWindow! Or it will not work!

UPDATE (Setting autoHideMenuBar on BrowserWindow construction)

As by @kcpr comment! We can set the property and many on the constructor

That’s available on the latest stable version of electron by now which is 8.3!
But too in old versions i checked for v1, v2, v3, v4!
It’s there in all versions!

From the doc for the option:

Here a snippet to illustrate it:

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

When you package your app the default menu won’t be there anymore, if this is bugging you during development then you can call setMenu(null) on the browser window as suggested by @TonyVincent.

electron js убрать меню. Смотреть фото electron js убрать меню. Смотреть картинку electron js убрать меню. Картинка про electron js убрать меню. Фото electron js убрать меню

setAutoHideMenuBar() still works, but could be a nuisance if you planned to use Alt as a hotkey modifier. Once menu is visible you have to click away from window (loose focus) to hide menu again.

If your application has more than one window, you can’t set/remove menus separately on each window. The only way to remove a menu is to use the frameless window approach. That happens to be what I want in my current application, but not a good solution in all cases.

Источник

Frameless Window

Open a window without toolbars, borders, or other graphical «chrome».

A frameless window is a window that has no chrome, the parts of the window, like toolbars, that are not a part of the web page. These are options on the BrowserWindow class.

Create a frameless window​

To create a frameless window, you need to set frame to false in BrowserWindow’s options :

Alternatives​

There’s an alternative way to specify a chromeless window on macOS and Windows. Instead of setting frame to false which disables both the titlebar and window controls, you may want to have the title bar hidden and your content extend to the full window size, yet still preserve the window controls («traffic lights» on macOS) for standard window actions. You can do so by specifying the titleBarStyle option:

hidden ​

Results in a hidden title bar and a full size content window. On macOS, the title bar still has the standard window controls (“traffic lights”) in the top left.

Alternatives on macOS​

hiddenInset ​

Results in a hidden title bar with an alternative look where the traffic light buttons are slightly more inset from the window edge.

customButtonsOnHover ​

Uses custom drawn close, and miniaturize buttons that display when hovering in the top left of the window. The fullscreen button is not available due to restrictions of frameless windows as they interface with Apple’s macOS window masks. These custom buttons prevent issues with mouse events that occur with the standard window toolbar buttons. This option is only applicable for frameless windows.

Windows Control Overlay​

When using a frameless window in conjuction with win.setWindowButtonVisibility(true) on macOS, using one of the titleBarStyle s as described above so that the traffic lights are visible, or using titleBarStyle: hidden on Windows, you can access the Window Controls Overlay JavaScript APIs and CSS Environment Variables by setting the titleBarOverlay option to true. Specifying true will result in an overlay with default system colors.

Transparent window​

Limitations​

Click-through window​

To create a click-through window, i.e. making the window ignore all mouse events, you can call the win.setIgnoreMouseEvents(ignore) API:

Forwarding​

Ignoring mouse messages makes the web page oblivious to mouse movement, meaning that mouse movement events will not be emitted. On Windows operating systems an optional parameter can be used to forward mouse move messages to the web page, allowing events such as mouseleave to be emitted:

Draggable region​

And note that if you have made the whole window draggable, you must also mark buttons as non-draggable, otherwise it would be impossible for users to click on them:

If you’re only setting a custom titlebar as draggable, you also need to make all buttons in titlebar non-draggable.

Text selection​

In a frameless window the dragging behavior may conflict with selecting text. For example, when you drag the titlebar you may accidentally select the text on the titlebar. To prevent this, you need to disable text selection within a draggable area like this:

Context menu​

On some platforms, the draggable area will be treated as a non-client frame, so when you right click on it a system menu will pop up. To make the context menu behave correctly on all platforms you should never use a custom context menu on draggable areas.

Источник

BrowserWindow

Create and control browser windows.

Window customization​

The BrowserWindow class exposes various ways to modify the look and behavior of your app’s windows. For more details, see the Window Customization tutorial.

Showing the window gracefully​

When loading a page in the window directly, users may see the page load incrementally, which is not a good experience for a native app. To make the window display without a visual flash, there are two solutions for different situations.

Using the ready-to-show event​

While loading the page, the ready-to-show event will be emitted when the renderer process has rendered the page for the first time if the window has not been shown yet. Showing the window after this event will have no visual flash:

This event is usually emitted after the did-finish-load event, but for pages with many remote resources, it may be emitted before the did-finish-load event.

Please note that using this event implies that the renderer will be considered «visible» and paint even though show is false. This event will never fire if you use paintWhenInitiallyHidden: false

Setting the backgroundColor property​

For a complex app, the ready-to-show event could be emitted too late, making the app feel slow. In this case, it is recommended to show the window immediately, and use a backgroundColor close to your app’s background:

Note that even for apps that use ready-to-show event, it is still recommended to set backgroundColor to make app feel more native.

Parent and child windows​

By using parent option, you can create child windows:

The child window will always show on top of the top window.

Modal windows​

A modal window is a child window that disables parent window, to create a modal window, you have to set both parent and modal options:

Page visibility​

The Page Visibility API works as follows:

It is recommended that you pause expensive operations when the visibility state is hidden in order to minimize power consumption.

Platform notices​

Class: BrowserWindow​

Create and control browser windows.

BrowserWindow is an EventEmitter.

new BrowserWindow([options]) ​

The possible values and behaviors of the type option are platform dependent. Possible values are:

Instance 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’​

Emitted when the document changed its title, calling event.preventDefault() will prevent the native window’s title from changing. explicitSet is false when title is synthesized from file URL.

Event: ‘close’​

Emitted when the window is going to be closed. It’s emitted before the beforeunload and unload event of the DOM. Calling event.preventDefault() will cancel the close.

Usually you would want to use the beforeunload handler to decide whether the window should be closed, which will also be called when the window is reloaded. In Electron, returning any value other than undefined would cancel the close. For example:

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 any more.

Event: ‘session-end’ Windows​

Emitted when window session is going to end due to force shutdown or machine restart or session log off.

Event: ‘unresponsive’​

Emitted when the web page becomes unresponsive.

Event: ‘responsive’​

Emitted when the unresponsive web page becomes responsive again.

Event: ‘blur’​

Emitted when the window loses focus.

Event: ‘focus’​

Emitted when the window gains focus.

Event: ‘show’​

Emitted when the window is shown.

Event: ‘hide’​

Emitted when the window is hidden.

Event: ‘ready-to-show’​

Emitted when the web page has been rendered (while not being shown) and window can be displayed without a visual flash.

Please note that using this event implies that the renderer will be considered «visible» and paint even though show is false. This event will never fire if you use paintWhenInitiallyHidden: false

Event: ‘maximize’​

Emitted when window is maximized.

Event: ‘unmaximize’​

Emitted when the window exits from a maximized state.

Event: ‘minimize’​

Emitted when the window is minimized.

Event: ‘restore’​

Emitted when the window is restored from a minimized state.

Event: ‘will-resize’ macOS Windows​

Emitted before the window is resized. Calling event.preventDefault() will prevent the window from being resized.

Note that this is only emitted when the window is being resized manually. Resizing the window with setBounds / setSize will not emit this event.

The possible values and behaviors of the edge option are platform dependent. Possible values are:

Event: ‘resize’​

Emitted after the window has been resized.

Event: ‘resized’ macOS Windows​

Emitted once when the window has finished being resized.

This is usually emitted when the window has been resized manually. On macOS, resizing the window with setBounds / setSize and setting the animate parameter to true will also emit this event once resizing has finished.

Event: ‘will-move’ macOS Windows​

Emitted before the window is moved. On Windows, calling event.preventDefault() will prevent the window from being moved.

Note that this is only emitted when the window is being resized manually. Resizing the window with setBounds / setSize will not emit this event.

Event: ‘move’​

Emitted when the window is being moved to a new position.

Event: ‘moved’ macOS Windows​

Emitted once when the window is moved to a new position.

Event: ‘enter-full-screen’​

Emitted when the window enters a full-screen state.

Event: ‘leave-full-screen’​

Emitted when the window leaves a full-screen state.

Event: ‘enter-html-full-screen’​

Emitted when the window enters a full-screen state triggered by HTML API.

Event: ‘leave-html-full-screen’​

Emitted when the window leaves a full-screen state triggered by HTML API.

Event: ‘always-on-top-changed’​

Emitted when the window is set or unset to show always on top of other windows.

Event: ‘app-command’ Windows Linux​

Emitted when an App Command 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.

The following app commands are explicitly supported on Linux:

Event: ‘scroll-touch-begin’ macOS​

Emitted when scroll wheel event phase has begun.

Event: ‘scroll-touch-end’ macOS​

Emitted when scroll wheel event phase has ended.

Event: ‘scroll-touch-edge’ macOS​

Emitted when scroll wheel event phase filed upon reaching the edge of element.

Event: ‘swipe’ macOS​

The method underlying this event is built to handle older macOS-style trackpad swiping, where the content on the screen doesn’t move with the swipe. Most macOS trackpads are not configured to allow this kind of swiping anymore, so in order for it to emit properly the ‘Swipe between pages’ preference in System Preferences > Trackpad > More Gestures must be set to ‘Swipe with two or three fingers’.

Event: ‘rotate-gesture’ macOS​

Event: ‘sheet-begin’ macOS​

Emitted when the window opens a sheet.

Event: ‘sheet-end’ macOS​

Emitted when the window has closed a sheet.

Event: ‘new-window-for-tab’ macOS​

Emitted when the native new tab button is clicked.

Event: ‘system-context-menu’ Windows​

Calling event.preventDefault() will prevent the menu from being displayed.

Static Methods​

The BrowserWindow class has the following static methods:

BrowserWindow.getAllWindows() ​

BrowserWindow.getFocusedWindow() ​

BrowserWindow.fromWebContents(webContents) ​

BrowserWindow.fromBrowserView(browserView) ​

BrowserWindow.fromId(id) ​

Instance Properties​

Objects created with new BrowserWindow have the following properties:

win.webContents Readonly​

A WebContents object this window owns. All web page related events and operations will be done via it.

See the webContents documentation for its methods and events.

win.id Readonly​

A Integer property representing the unique ID of the window. Each ID is unique among all BrowserWindow instances of the entire Electron application.

win.autoHideMenuBar ​

A Boolean property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single Alt key.

If the menu bar is already visible, setting this property to true won’t hide it immediately.

win.simpleFullScreen ​

A Boolean property that determines whether the window is in simple (pre-Lion) fullscreen mode.

win.fullScreen ​

A Boolean property that determines whether the window is in fullscreen mode.

win.focusable Windows macOS​

A Boolean property that determines whether the window is focusable.

win.visibleOnAllWorkspaces ​

A Boolean property that determines whether the window is visible on all workspaces.

Note: Always returns false on Windows.

win.shadow ​

A Boolean property that determines whether the window has a shadow.

win.menuBarVisible Windows Linux​

A Boolean property that determines whether the menu bar should be visible.

Note: If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single Alt key.

win.kiosk ​

A Boolean property that determines whether the window is in kiosk mode.

win.documentEdited macOS​

A Boolean property that specifies whether the window’s document has been edited.

win.representedFilename macOS​

A String property that determines the pathname of the file the window represents, and the icon of the file will show in window’s title bar.

win.title ​

A String property that determines the title of the native window.

Note: The title of the web page can be different from the title of the native window.

win.minimizable ​

A Boolean property that determines whether the window can be manually minimized by user.

win.maximizable ​

A Boolean property that determines whether the window can be manually maximized by user.

win.fullScreenable ​

A Boolean property that determines whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

win.resizable ​

A Boolean property that determines whether the window can be manually resized by user.

win.closable ​

A Boolean property that determines whether the window can be manually closed by user.

win.movable ​

A Boolean property that determines Whether the window can be moved by user.

win.excludedFromShownWindowsMenu macOS​

A Boolean property that determines whether the window is excluded from the application’s Windows menu. false by default.

win.accessibleTitle ​

A String property that defines an alternative title provided only to accessibility tools such as screen readers. This string is not directly visible to users.

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() ​

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() ​

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.

win.focus() ​

Focuses on the window.

win.blur() ​

Removes focus from the window.

win.isFocused() ​

win.isDestroyed() ​

win.show() ​

Shows and gives focus to the window.

win.showInactive() ​

Shows the window but doesn’t focus on it.

win.hide() ​

win.isVisible() ​

win.isModal() ​

win.maximize() ​

Maximizes the window. This will also show (but not focus) the window if it isn’t being displayed already.

win.unmaximize() ​

Unmaximizes the window.

win.isMaximized() ​

win.minimize() ​

Minimizes the window. On some platforms the minimized window will be shown in the Dock.

win.restore() ​

Restores the window from minimized state to its previous state.

win.isMinimized() ​

win.setFullScreen(flag) ​

Sets whether the window should be in fullscreen mode.

win.isFullScreen() ​

win.setSimpleFullScreen(flag) macOS​

Enters or leaves simple fullscreen mode.

Simple fullscreen mode emulates the native fullscreen behavior found in versions of macOS prior to Lion (10.7).

win.isSimpleFullScreen() macOS​

win.isNormal() ​

win.setAspectRatio(aspectRatio[, extraSize]) ​

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.

Consider a normal window with an HD video player and associated controls. Perhaps there are 15 pixels of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920×1080) within the player itself we would call this function with arguments of 16/9 and < width: 40, height: 50 >. The second argument doesn’t care where the extra width and height are within the content view—only that they exist. Sum any extra width and height areas you have within the overall content view.

win.setBackgroundColor(backgroundColor) ​

win.previewFile(path[, displayName]) macOS​

Uses Quick Look to preview a file at a given path.

win.closeFilePreview() macOS​

Closes the currently open Quick Look panel.

win.setBounds(bounds[, animate]) ​

Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.

win.getBounds() ​

win.getBackgroundColor() ​

win.setContentBounds(bounds[, animate]) ​

Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds.

win.getContentBounds() ​

win.getNormalBounds() ​

Note: whatever the current state of the window : maximized, minimized or in fullscreen, this function always returns the position and size of the window in normal state. In normal state, getBounds and getNormalBounds returns the same Rectangle.

win.setEnabled(enable) ​

Disable or enable the window.

win.isEnabled() ​

win.setSize(width, height[, animate]) ​

win.getSize() ​

win.setContentSize(width, height[, animate]) ​

win.getContentSize() ​

win.setMinimumSize(width, height) ​

win.getMinimumSize() ​

win.setMaximumSize(width, height) ​

win.getMaximumSize() ​

win.setResizable(resizable) ​

Sets whether the window can be manually resized by the user.

win.isResizable() ​

win.setMovable(movable) macOS Windows​

Sets whether the window can be moved by user. On Linux does nothing.

win.isMovable() macOS Windows​

win.setMinimizable(minimizable) macOS Windows​

Sets whether the window can be manually minimized by user. On Linux does nothing.

win.isMinimizable() macOS Windows​

win.setMaximizable(maximizable) macOS Windows​

Sets whether the window can be manually maximized by user. On Linux does nothing.

win.isMaximizable() macOS Windows​

win.setFullScreenable(fullscreenable) ​

Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

win.isFullScreenable() ​

win.setClosable(closable) macOS Windows​

Sets whether the window can be manually closed by user. On Linux does nothing.

win.isClosable() macOS Windows​

win.setAlwaysOnTop(flag[, level][, relativeLevel]) ​

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.moveAbove(mediaSourceId) ​

Moves window above the source window in the sense of z-order. If the mediaSourceId is not of type window or if the window does not exist then this method throws an error.

win.moveTop() ​

Moves window to top(z-order) regardless of focus

win.center() ​

Moves window to the center of the screen.

win.setPosition(x, y[, animate]) ​

win.getPosition() ​

win.setTitle(title) ​

win.getTitle() ​

Note: The title of the web page can be different from the title of the native window.

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 a HTML-rendered toolbar. For example:

win.flashFrame(flag) ​

Starts or stops flashing the window to attract user’s attention.

win.setSkipTaskbar(skip) ​

Makes the window not show in the taskbar.

win.setKiosk(flag) ​

Enters or leaves kiosk mode.

win.isKiosk() ​

win.isTabletMode() Windows​

Since Windows 10 users can use their PC as tablet, under this mode apps can choose to optimize their UI for tablets, such as enlarging the titlebar and hiding titlebar buttons.

This API returns whether the window is in tablet mode, and the resize event can be be used to listen to changes to tablet mode.

win.getMediaSourceId() ​

More precisely the format is window:id:other_id where id is HWND on Windows, CGWindowID ( uint64_t ) on macOS and Window ( unsigned long ) on Linux. other_id is used to identify web contents (tabs) so within the same top level window.

win.getNativeWindowHandle() ​

The native type of the handle is HWND on Windows, NSView* on macOS, and Window ( unsigned long ) on Linux.

win.hookWindowMessage(message, callback) Windows​

Hooks a windows message. The callback is called when the message is received in the WndProc.

win.isWindowMessageHooked(message) Windows​

win.unhookWindowMessage(message) Windows​

Unhook the window message.

win.unhookAllWindowMessages() Windows​

Unhooks all of the window messages.

win.setRepresentedFilename(filename) macOS​

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.setDocumentEdited(edited) macOS​

win.isDocumentEdited() macOS​

win.focusOnWebView() ​

win.blurWebView() ​

win.capturePage([rect]) ​

win.loadURL(url[, options]) ​

The url can be a remote address (e.g. http:// ) or a path to a local HTML file using the file:// protocol.

To ensure that file URLs are properly formatted, it is recommended to use Node’s url.format method:

You can load a URL using a POST request with URL-encoded data by doing the following:

win.loadFile(filePath[, options]) ​

win.reload() ​

win.setMenu(menu) Linux Windows​

Sets the menu as the window’s menu bar.

win.removeMenu() Linux Windows​

Remove the window’s menu bar.

win.setProgressBar(progress[, options]) ​

Remove progress bar when progress 1.

win.setOverlayIcon(overlay, description) Windows​

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) ​

Sets whether the window should have a shadow.

win.hasShadow() ​

win.setOpacity(opacity) Windows macOS​

Sets the opacity of the window. On Linux, does nothing. Out of bound number values are clamped to the [0, 1] range.

win.getOpacity() ​

win.setShape(rects) Windows Linux Experimental​

Setting a window shape determines the area within the window where the system permits drawing and user interaction. Outside of the given region, no pixels will be drawn and no mouse events will be registered. Mouse events outside of the region will not be received by that window, but will fall through to whatever is behind the window.

win.setThumbarButtons(buttons) Windows​

Add a thumbnail toolbar with a specified set of buttons to the thumbnail image of a window in a taskbar button layout. Returns a Boolean object indicates whether the thumbnail has been added successfully.

The number of buttons in thumbnail toolbar should be no greater than 7 due to the limited room. Once you setup the thumbnail toolbar, the toolbar cannot be removed due to the platform’s limitation. But you can call the API with an empty array to clean the buttons.

The buttons is an array of Button objects:

The flags is an array that can include following String s:

win.setThumbnailClip(region) Windows​

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.setThumbnailToolTip(toolTip) Windows​

Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar.

win.setAppDetails(options) Windows​

Sets the properties for the window’s taskbar button.

Note: relaunchCommand and relaunchDisplayName must always be set together. If one of those properties is not set, then neither will be used.

win.showDefinitionForSelection() macOS​

win.setIcon(icon) Windows Linux​

Changes window icon.

win.setWindowButtonVisibility(visible) macOS​

Sets whether the window traffic light buttons should be visible.

win.setAutoHideMenuBar(hide) ​

Sets whether the window menu bar should hide itself automatically. Once set the menu bar will only show when users press the single Alt key.

If the menu bar is already visible, calling setAutoHideMenuBar(true) won’t hide it immediately.

win.isMenuBarAutoHide() ​

win.setMenuBarVisibility(visible) Windows Linux​

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.setVisibleOnAllWorkspaces(visible[, options]) ​

Sets whether the window should be visible on all workspaces.

Note: This API does nothing on Windows.

win.isVisibleOnAllWorkspaces() ​

Note: This API always returns false on Windows.

win.setIgnoreMouseEvents(ignore[, options]) ​

Makes the window ignore all mouse events.

All mouse events happened in this window will be passed to the window below this window, but if this window has focus, it will still receive keyboard events.

win.setContentProtection(enable) macOS Windows​

Prevents the window contents from being captured by other apps.

win.setFocusable(focusable) macOS Windows​

Changes whether the window can be focused.

On macOS it does not remove the focus from the window.

win.isFocusable() macOS Windows​

Returns whether the window can be focused.

win.setParentWindow(parent) ​

Sets parent as current window’s parent window, passing null will turn current window into a top-level window.

win.getParentWindow() ​

win.getChildWindows() ​

win.setAutoHideCursor(autoHide) macOS​

Controls whether to hide cursor when typing.

win.selectPreviousTab() macOS​

Selects the previous tab when native tabs are enabled and there are other tabs in the window.

win.selectNextTab() macOS​

Selects the next tab when native tabs are enabled and there are other tabs in the window.

win.mergeAllWindows() macOS​

Merges all windows into one window with multiple tabs when native tabs are enabled and there is more than one open window.

win.moveTabToNewWindow() macOS​

Moves the current tab into a new window if native tabs are enabled and there is more than one tab in the current window.

win.toggleTabBar() macOS​

Toggles the visibility of the tab bar if native tabs are enabled and there is only one tab in the current window.

win.addTabbedWindow(browserWindow) macOS​

Adds a window as a tab on this window, after the tab for the window instance.

win.setVibrancy(type) macOS​

Adds a vibrancy effect to the browser window. Passing null or an empty string will remove the vibrancy effect on the window.

win.setTrafficLightPosition(position) macOS​

Set a custom position for the traffic light buttons in frameless window.

win.getTrafficLightPosition() macOS​

win.setTouchBar(touchBar) macOS​

Sets the touchBar layout for the current window. Specifying null or undefined clears the touch bar. This method only has an effect if the machine has a touch bar and is running on macOS 10.12.1+.

Note: The TouchBar API is currently experimental and may change or be removed in future Electron releases.

win.setBrowserView(browserView) Experimental​

win.getBrowserView() Experimental​

win.addBrowserView(browserView) Experimental​

Replacement API for setBrowserView supporting work with multi browser views.

win.removeBrowserView(browserView) Experimental​

win.setTopBrowserView(browserView) Experimental​

win.getBrowserViews() Experimental​

Note: The BrowserView API is currently experimental and may change or be removed in future Electron releases.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *