Simulate the toggleDevTools API.
Currently there is no way to know the devtools's state in brightray, so we have to record the state manually, fix this after patching brightray.
This commit is contained in:
parent
61bca04dfd
commit
1fea283d91
2 changed files with 13 additions and 3 deletions
|
@ -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()
|
||||
|
|
|
@ -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(); }
|
||||
},
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue