Hi There,
I have developed a webextension which has an “input” in the layout. When i right click anywhere on the popup.html including the “input” filed, the context menu is not appearing.
Looks like its disabled by default. Is there a way to enable it?
A sample Addon where righ click is not working
https://emojikeyboard.org/
Thanks
Rakesh
NilkasG
(Niklas Gollenstede)
May 4, 2017, 5:43pm
2
I don’t think you can “enable” it.
You will have to create your own. In one of my (unpublished) WebExtensions I do that.
In all my tests, this implementation works very well and is quite close to a native menu. It supports default values, keyboard input, nested menus, avoids overflowing and can display checkboxes and icons:
https://github.com/NiklasGollenstede/youtube/blob/master/common/context-menu.js
I have not documented its (simple) API yet. An example use can be found here:
enableDragOut(tiles);
const addTile = ({ videoId, bookmarkId, }) => (tiles.appendChild(Object.assign(new MediaTile, { videoId, })).dataset.bookmarkId = bookmarkId);
entries.forEach(addTile);
});
const onRemoved = bookmarkId => document.querySelector(`media-tile[data-bookmark-id="${ bookmarkId }"]`).remove();
Bookmarks.onRemoved.addListener(onRemoved); window.addEventListener('unload', () => Bookmarks.onRemoved.removeListener(onRemoved));
})();
{ // controls
options.playlist.children.loop.whenChange(([ value, ]) => document.querySelector('#loop').classList[value ? 'add' : 'remove']('active'), off);
Player.onPlay(playing, off); Player.playing && playing(true);
function playing(playing) {
document.querySelector( playing ? '#play' : '#pause').classList.add('active');
document.querySelector(!playing ? '#play' : '#pause').classList.remove('active');
const active = playing && document.querySelector('#playlist:not(:hover) .tiles media-tile.active');
active && scrollToCenter(active);
}
}
{ // seek-bar
let looping = false, lastSec = -1;
Here is the result with a dark theme:
I’ve recently created an API request to show custom menus, which would solve this mess:
https://bugzilla.mozilla.org/show_bug.cgi?id=1364401
Showing an HTML Menu is not always a viable option (if the menu is bigger than the popup for example)
I recently fixed context menus in popups. You’ll get them with Firefox 55. See https://bugzilla.mozilla.org/show_bug.cgi?id=1299371
You can add items to the native context menu using both the WebExtension and the HTML context menu API.
1 Like