wshanks / tbkeys

Custom keybindings for Thunderbird
Other
184 stars 13 forks source link

A command of a contextual menu item #171

Open babalooza opened 1 month ago

babalooza commented 1 month ago

Hi,

is it possible to map a command of a contextual menu item?

I use grouped folders and I want to delete all junk emails from several email addresses in the grouped junk folder with a keyboard shortcut. Right now on my Mac I have to right-click (or control-click) the grouped junk folder and select "delete junk" from the pop up menu. And that's what I want to do with a shortcut.

If that is possible, can I use the keyboard shortcut "option + command + J", because that is the keyboard shortcut in Apple Mail for the same action.

Thanks in advance!

morat523035 commented 1 month ago

Are you talking about the "Empty Junk" context menu item in the Unified Folders Junk folder?

Thunderbird 115:

window.gTabmail.currentAbout3Pane.folderPane.emptyJunk(window.gTabmail.currentAbout3Pane.gFolder);

I don't use junk commands so I didn't test it.

Reference http://searchfox.org/comm-esr115/search?q=mptyJunk

You cannot run arbitrary javascript with tbkeys-lite. There is a tbkeys.xpi link on the GitHub releases page.

babalooza commented 1 month ago

Yes, the "Empty Junk" context menu item is exactly what I mean. So your command looks to be the rteal deal. I just don't know where to put it. In tbkeys settings into the "Main key bindings" area or into "Compose key bindings"? And what would the line look like, if I want to press option+command+J in order to trigger the command?

Thanks in advance!

morat523035 commented 1 month ago

Use the main key bindings section for the main window. Use the compose key bindings section for the compose window.

The following json works for me in the main key bindings section on Windows.

{
  "f1": "window.alert('test one');",
  "ctrl+shift+j": "window.alert('test two');"
}

Try replacing ctrl+shift+j with option+command+j in the json, then test.

Then try replacing the below command with the above command in the json, then test again.

window.alert('test two');

Mousetrap docs (see SUPPORTED KEYS section) http://craig.is/killing/mice

Troubleshooting http://forums.mozillazine.org/viewtopic.php?p=14872763#p14872763

babalooza commented 1 month ago

Ok, I am getting there. First it didn't work because I added your lines behind/after the default commands and forgot to add the trailing comma behind the last default command. I have no coding skills whatsoever.

But after adding the comma the alerts are working, including option+command+j! Now, how does the json have to look like for emptying the junk? Can you help once more, morat?

morat523035 commented 1 month ago

Try this:

{
  "option+command+j": "window.gTabmail.currentAbout3Pane.folderPane.emptyJunk(window.gTabmail.currentAbout3Pane.gFolder);"
}

I don't use junk commands so I didn't test it.

babalooza commented 1 month ago

That works! Thanks a lot!!