5

I’m trying to add simple keyboard shortcuts (together with menu item) to my paclet through FrontEndExecute which works fine in notebook, but as soon as I put it into my paclet and import it the menu item is stripped from the keyboard shortcut. Is this due to security requirements on paclets or is there perhaps a way around it? I know about KeyEventTranslations.tr but I’d rather not use it.

Here's the minimal example about which I'm talking about:

FrontEndExecute[FrontEnd`AddMenuCommands["DuplicatePreviousOutput",

{Delimiter, MenuItem["Test", FrontEndExecute@Print[2], 

MenuKey["d", Modifiers -> {"Command"}], System`MenuEvaluator -> Automatic]}]];
Ranza
  • 1,205
  • 9
  • 22
  • 2
    Try to replace MenuKey and Modifiers with System`MenuKey and System`Modifiers, respectively. (Note how those two symbols are blue when you copy your code into a notebook, suggesting the kernel doesn't know about those symbols, meaning they will be created in the paclet context instead of the correct one when you execute your code from within a paclet) – Lukas Lang Jan 22 '20 at 19:55
  • It works! Thank you, that has been very quick and straight to the point! – Ranza Jan 22 '20 at 20:09
  • closely related: 102189 – Kuba Jan 23 '20 at 09:32

0 Answers0