diff --git a/browser/api/lib/browser_window.coffee b/browser/api/lib/browser_window.coffee index 24810af2c90..fc18a80717f 100644 --- a/browser/api/lib/browser_window.coffee +++ b/browser/api/lib/browser_window.coffee @@ -1,8 +1,18 @@ EventEmitter = require('events').EventEmitter +v8Util = process.atomBinding 'v8_util' objectsRegistry = require '../../atom/objects_registry.js' BrowserWindow = process.atomBinding('window').BrowserWindow -BrowserWindow.prototype.__proto__ = EventEmitter.prototype +BrowserWindow::__proto__ = EventEmitter.prototype + +BrowserWindow::toggleDevTools = -> + opened = v8Util.getHiddenValue this, 'devtoolsOpened' + if opened + @closeDevTools() + v8Util.setHiddenValue this, 'devtoolsOpened', false + else + @openDevTools() + v8Util.setHiddenValue this, 'devtoolsOpened', true BrowserWindow.getFocusedWindow = -> windows = objectsRegistry.getAllWindows() diff --git a/browser/default_app/main.js b/browser/default_app/main.js index bde619ed7f1..e5be6c92ea6 100644 --- a/browser/default_app/main.js +++ b/browser/default_app/main.js @@ -74,9 +74,9 @@ delegate.browserMainParts.preMainMessageLoopRun = function() { click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); } }, { - label: 'Show DevTools', + label: 'Toggle DevTools', accelerator: 'Alt+Command+I', - click: function() { BrowserWindow.getFocusedWindow().openDevTools(); } + click: function() { BrowserWindow.getFocusedWindow().toggleDevTools(); } }, ] },