MozillaZine

[WebExt] How to detect right click on item in context menu

Talk about add-ons and extension development.
Orangutan100
 
Posts: 51
Joined: July 9th, 2015, 11:56 am

Post Posted December 24th, 2016, 10:06 am

Hello,

I am using this webextension - Reverse Image Search. It shows a context menu upon right clicking an image, like this:

Image

I can then click any of the 'Search this image on...' items to search in a new tab.

What I would like to do is allow opening the search page on the same tab if the user right clicks any of these 'Search this image on...' items (and to limit the current behaviour of opening in a new tab for left clicks only).

Also, a minor issue, but from what I understand, a context menu item created by a webextension gets the same icon as that of the extension - is there a way to not show any icon on such a menu item?

I would appreciate any help. Thanks!

morat
 
Posts: 2905
Joined: February 3rd, 2009, 6:29 pm

Post Posted December 27th, 2016, 5:36 am

How do you detect a right click on a context menu item? It's not possible.

https://developer.mozilla.org/en-US/Add ... ntextMenus
https://developer.chrome.com/extensions/contextMenus

How do you detect a middle click on a browser action? It's not possible.

https://developer.mozilla.org/en-US/Add ... wserAction
https://developer.chrome.com/extensions/browserAction

You can't get the click event with the WebExtensions API.

Orangutan wrote:a minor issue

How do you set the icon on a context menu item? It's not possible.

How do you set the icon on a browser action? You can use the browserAction.setIcon method.

The contextMenus.setIcon method does not exist.

Orangutan100
 
Posts: 51
Joined: July 9th, 2015, 11:56 am

Post Posted December 28th, 2016, 12:32 pm

That's a bummer :/

Thanks for letting me know though.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 3 guests