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

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

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

Post by Orangutan100 »

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: 6421
Joined: February 3rd, 2009, 6:29 pm

Re: [WebExt] How to detect right click on item in context me

Post by morat »

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: 54
Joined: July 9th, 2015, 11:56 am

Re: [WebExt] How to detect right click on item in context me

Post by Orangutan100 »

That's a bummer :/

Thanks for letting me know though.
Post Reply