5
$\begingroup$

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]}]];
$\endgroup$
  • 2
    $\begingroup$ 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) $\endgroup$ – Lukas Lang Jan 22 at 19:55
  • $\begingroup$ It works! Thank you, that has been very quick and straight to the point! $\endgroup$ – Ranza Jan 22 at 20:09
  • $\begingroup$ closely related: 102189 $\endgroup$ – Kuba Jan 23 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.