12
$\begingroup$

Is it possible to add an entirely new menu, say menu "CustomApp" on the fly?

For example a CustomApp package could add its own menu "CustomApp" with submenus, ect, once Needed.

Former examples I have seen, only dealt with adding to an existing menu.

$\endgroup$
  • $\begingroup$ possible duplicate of How make AddMenuCommands work in an init.m $\endgroup$ – Szabolcs May 30 '12 at 16:25
  • $\begingroup$ Or maybe this one: mathematica.stackexchange.com/q/907/12 $\endgroup$ – Szabolcs May 30 '12 at 16:26
  • $\begingroup$ I was too quick to mark as duplicate, I am sorry. You are right that the other examples add to existing menus, and don't add a new menu. $\endgroup$ – Szabolcs May 30 '12 at 21:00
  • $\begingroup$ AFAIK you can only do this by manually altering the MenuSetup.tr file -- but will be interested in other methods are available. $\endgroup$ – Mike Honeychurch May 30 '12 at 23:31
  • $\begingroup$ @Szabolcs No problem :-) $\endgroup$ – magma May 31 '12 at 0:48
10
$\begingroup$

You can't add an entirely new menu using AddMenuCommands. We have it from John Fultz here:

"AddMenuCommands can only position a menu relative to one with a simple front end token."

(I trust I've not taken that out of context.)

$\endgroup$
  • $\begingroup$ I feared that. Still..is it possible to force MMA to read and apply a new MenuSetup.tr file during a session? maybe by restarting the fron-end? $\endgroup$ – magma May 31 '12 at 0:52
  • $\begingroup$ This isn't actually the case. You can programmatically edit and then apply using FrontEnd`ResetMenusPacket $\endgroup$ – b3m2a1 Aug 27 '18 at 10:51
5
$\begingroup$

You can change the Mathematica menu in the way you desire by editing the MenuSetup.tr file, and restarting Mathematica. I make this change each time I get a new version of Mathematica.

Of course, this isn't ideal, because it involves making a permanent change to the system, but it does work - just follow the style of the rest of the file.

Be careful to back up the original file, and make your changes a little at a time, because Mathematica isn't very informative if you get the syntax wrong. Don't use operators in this file - last time I tried, they failed.

$\endgroup$
  • $\begingroup$ Thank you David, this was known, but the real point is: can we do this programmatically? Can a user-package do this and then perhaps programmatically restart the fron-end so that the new Menu takes effect? You can see from my comment above in Degnen's answer and in the question text that the real challenge lies in doing this programmatically. $\endgroup$ – magma Aug 21 '14 at 9:45
3
$\begingroup$

This is actually entirely possible. See, for example, this. All you need to do is use FrontEnd`ResetMenusPacket on a new Menu expression.

Beware that if you get rid of too much you'll crash Mathematica. I've never had an issue from adding new menus, though.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.