Fix displaying context menu for devtools
This commit is contained in:
parent
af72842728
commit
651dabf47e
2 changed files with 10 additions and 6 deletions
|
@ -37,9 +37,11 @@ for arg in process.argv
|
||||||
if location.protocol is 'chrome-devtools:'
|
if location.protocol is 'chrome-devtools:'
|
||||||
# Override some inspector APIs.
|
# Override some inspector APIs.
|
||||||
require path.join(__dirname, 'inspector')
|
require path.join(__dirname, 'inspector')
|
||||||
|
nodeIntegration = 'true'
|
||||||
else if location.protocol is 'chrome-extension:'
|
else if location.protocol is 'chrome-extension:'
|
||||||
# Add implementations of chrome API.
|
# Add implementations of chrome API.
|
||||||
require path.join(__dirname, 'chrome-api')
|
require path.join(__dirname, 'chrome-api')
|
||||||
|
nodeIntegration = 'true'
|
||||||
else
|
else
|
||||||
# Override default web functions.
|
# Override default web functions.
|
||||||
require path.join(__dirname, 'override')
|
require path.join(__dirname, 'override')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
window.onload = ->
|
window.onload = ->
|
||||||
# Use menu API to show context menu.
|
# Use menu API to show context menu.
|
||||||
InspectorFrontendHost.showContextMenu = (event, items) ->
|
InspectorFrontendHost.showContextMenuAtPoint = (x, y, items, document) ->
|
||||||
createMenu items, event
|
createMenu items
|
||||||
|
|
||||||
# Use dialog API to override file chooser dialog.
|
# Use dialog API to override file chooser dialog.
|
||||||
WebInspector.createFileSelectorElement = (callback) ->
|
WebInspector.createFileSelectorElement = (callback) ->
|
||||||
|
@ -32,17 +32,19 @@ convertToMenuTemplate = (items) ->
|
||||||
label: item.label
|
label: item.label
|
||||||
enabled: item.enabled
|
enabled: item.enabled
|
||||||
if item.id?
|
if item.id?
|
||||||
transformed.click = -> WebInspector.contextMenuItemSelected item.id
|
transformed.click = -> InspectorFrontendAPI.contextMenuItemSelected item.id
|
||||||
template.push transformed
|
template.push transformed
|
||||||
template
|
template
|
||||||
|
|
||||||
createMenu = (items, event) ->
|
createMenu = (items) ->
|
||||||
remote = require 'remote'
|
remote = require 'remote'
|
||||||
Menu = remote.require 'menu'
|
Menu = remote.require 'menu'
|
||||||
|
|
||||||
menu = Menu.buildFromTemplate convertToMenuTemplate(items)
|
menu = Menu.buildFromTemplate convertToMenuTemplate(items)
|
||||||
menu.popup remote.getCurrentWindow()
|
# The menu is expected to show asynchronously.
|
||||||
event.consume true
|
setImmediate ->
|
||||||
|
menu.popup remote.getCurrentWindow()
|
||||||
|
InspectorFrontendAPI.contextMenuCleared()
|
||||||
|
|
||||||
showFileChooserDialog = (callback) ->
|
showFileChooserDialog = (callback) ->
|
||||||
remote = require 'remote'
|
remote = require 'remote'
|
||||||
|
|
Loading…
Reference in a new issue