diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index 6adc548bcc..a0a4792dd1 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -1146,9 +1146,10 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate, &TopLevelWindow::IsExcludedFromShownWindowsMenu, &TopLevelWindow::SetExcludedFromShownWindowsMenu) #endif - .SetMethod("setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar) - .SetMethod("isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide) - .SetMethod("setMenuBarVisibility", &TopLevelWindow::SetMenuBarVisibility) + .SetMethod("_setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar) + .SetMethod("_isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide) + .SetProperty("autoHideMenuBar", &TopLevelWindow::IsMenuBarAutoHide, + &TopLevelWindow::SetAutoHideMenuBar) .SetMethod("isMenuBarVisible", &TopLevelWindow::IsMenuBarVisible) .SetMethod("setAspectRatio", &TopLevelWindow::SetAspectRatio) .SetMethod("previewFile", &TopLevelWindow::PreviewFile) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 44c8e7307c..cac2a29fb1 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -1470,10 +1470,14 @@ 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. +**[Deprecated](modernization/property-updates.md)** + #### `win.isMenuBarAutoHide()` Returns `Boolean` - Whether menu bar automatically hides itself. +**[Deprecated](modernization/property-updates.md)** + #### `win.setMenuBarVisibility(visible)` _Windows_ _Linux_ * `visible` Boolean @@ -1642,6 +1646,13 @@ removed in future Electron releases. ### Properties +#### `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.excludedFromShownWindowsMenu` _macOS_ A `Boolean` property that determines whether the window is excluded from the application’s Windows menu. `false` by default. diff --git a/docs/api/modernization/property-updates.md b/docs/api/modernization/property-updates.md index b839e36c61..d13292eb5d 100644 --- a/docs/api/modernization/property-updates.md +++ b/docs/api/modernization/property-updates.md @@ -22,7 +22,6 @@ The Electron team is currently undergoing an initiative to convert separate gett * `title` * `documentEdited` * `hasShadow` - * `autohideMenuBar` * `menubarVisible` * `visibleOnAllWorkspaces` * `crashReporter` module @@ -54,6 +53,8 @@ The Electron team is currently undergoing an initiative to convert separate gett * `applicationMenu` * `badgeCount` * `name` +* `BrowserWindow` module + * `autohideMenuBar` * `NativeImage` * `isMacTemplateImage` * `SystemPreferences` module diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 40deda8e30..4c427a6099 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -1,7 +1,7 @@ 'use strict' const electron = require('electron') -const { WebContentsView, TopLevelWindow } = electron +const { WebContentsView, TopLevelWindow, deprecate } = electron const { BrowserWindow } = process.electronBinding('window') Object.setPrototypeOf(BrowserWindow.prototype, TopLevelWindow.prototype) @@ -191,4 +191,7 @@ Object.assign(BrowserWindow.prototype, { } }) +// Deprecations +deprecate.fnToProperty(BrowserWindow.prototype, 'autoHideMenuBar', '_isMenuBarAutoHide', '_setAutoHideMenuBar') + module.exports = BrowserWindow diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 09a80b20c5..6ccab009aa 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -513,6 +513,16 @@ describe('BrowserWindow module', () => { }) }) + describe('BrowserWindow autoHideMenuBar property', () => { + it('has an autoHideMenuBar property', () => { + expect(w).to.have.a.property('autoHideMenuBar') + + // TODO(codebytere): remove when propertyification is complete + expect(w.setAutoHideMenuBar).to.be.a('function') + expect(w.isMenuBarAutoHide).to.be.a('function') + }) + }) + describe('BrowserWindow.moveTop()', () => { it('should not steal focus', async () => { const posDelta = 50