Hey guys,
I’m having troubles using shortkeys/commands.
In my extension I use a context menu, doing this for example:
browser.contextMenus.onClicked.addListener(contextMenuAction);
browser.contextMenus.create({
id: "1 Host Connect",
title: "1 Host Connect",
contexts: ["selection"]
});
function contextMenuAction(info, tab) {
switch (info.menuItemId) {
case "1 Host Connect":
browser.tabs.create({index: 1,url: "xyz://"+info.selectionText.trim()+"/"});
break;
}
}
That works well and as expected. Now I want to achieve the same thing with a shortcut using commands.
So I defined ALT+1 for the above context menu point action. But I’m having troubles making it work, passing the same information as with browser.contextMenus.onClicked.addListener(contextMenuAction), meaning tab,info.
How can I achieve the same result uPreformatted textsing commands? Doing something like this doesn’t work since info and tab are not defined:
function HotkeyContextMenuAction(info, tab) {
browser.tabs.create({index: 1,url: "xyz://"+info.selectionText.trim()+"/"});
}
browser.commands.onCommand.addListener(function(command,info,tab) {
if (command == "1 Host Connect") {
console.log('HOTKEY');
HotkeyContextMenuAction(info,tab);
}
});
Now, I am a total beginner when it comes to extension development, so please bear with me.
Many thanks i advance!!!
Kind regards,
David