如何在Google Chrome中设置上下文菜单,以便所有菜单都是顶级菜单? [英] How can I set up a context menu in Google Chrome so that all of the menu are top level?
问题描述
我正在使用Google Chrome浏览器扩展程序,并且已经设置了多个右键单击上下文菜单项。我发现添加一个菜单项可以让你选择一个parentID,但是我没有看到任何可以让你选择将所有菜单项作为顶级项目的语法。
下面是我的插件的一个例子,它带有一个顶级菜单项,然后是几个子菜单项:
我想把它们带到最高层,因为我使用它们很多。这是我到目前为止的代码,但我无法弄清楚如何将它们全部拉上一级:
chrome.contextMenus.create({'title':'发送URL到Quicksilver',
'contexts':['all'],
'onclick':sendToQuicksilver});
chrome.contextMenus.create({'title':'发送文件到Quicksilver',
'contexts':['all'],
'onclick':sendFileToQuicksilver} );
chrome.contextMenus.create({'title':'Quick Download',
'contexts':['all'],
'onclick': quickDownload});
$ b chrome.contextMenus.create({'title':'在Textmate中编辑',
'contexts':['all'],
'onclick' :editInTextmate});
chrome.contextMenus.create({'title':'在Textmate中打开项目',
'contexts':['all'],
'onclick ':editProjectInTextmate});
这是不可能的,您只能创建一个顶级菜单。
从规格:
您可以根据需要创建任意数量的上下文菜单项,但是如果您的扩展程序中有多个可以同时看到,Chrome浏览器会自动将它们折叠到一个父级菜单中。
I am working on a Google Chrome extension and I have set up several right click context menu items. I see that there is something in the syntax for adding a menu item which allows you to choose a parentID, but I don't see anything that would allow you to choose to have all the menu items as top level items.
Here's an example of my plugin with a single top level menu item and then several sub menu items:
I'd like to bring those out to the top level because I use them a lot. This is the code that I have so far, but I can't figure out how to pull them all up a level:
chrome.contextMenus.create({'title': 'Send URL to Quicksilver',
'contexts': ['all'],
'onclick': sendToQuicksilver});
chrome.contextMenus.create({'title': 'Send File to Quicksilver',
'contexts': ['all'],
'onclick': sendFileToQuicksilver});
chrome.contextMenus.create({'title': 'Quick Download',
'contexts': ['all'],
'onclick': quickDownload});
chrome.contextMenus.create({'title': 'Edit in Textmate',
'contexts': ['all'],
'onclick': editInTextmate});
chrome.contextMenus.create({'title': 'Open Project in Textmate',
'contexts': ['all'],
'onclick': editProjectInTextmate});
It's not possible, you are allowed to create only one top level menu per extension.
From specs:
You can create as many context menu items as you need, but if more than one from your extension is visible at once, Google Chrome automatically collapses them into a single parent menu.
这篇关于如何在Google Chrome中设置上下文菜单,以便所有菜单都是顶级菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!