Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set up a context menu in Google Chrome so that all of the menu are top level?

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:

Screen shot 2011-10-10 at 11.51.00 PM.png

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});
like image 645
cwd Avatar asked Dec 27 '22 13:12

cwd


1 Answers

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.

like image 54
serg Avatar answered May 08 '23 15:05

serg