I have a Grid and need to enable some actions on individual values. For this I want to use an ActionMenu that shows on right-click of the grid cell.

This should behave just as the normal right-click menu.
On a selection being made the action would evaluate and the ActionMenu would disappear.
On clicking anywhere off of the ActionMenu it would disappear.

I am stuck on the first part of showing the ActionMenu. I know I need to use CurrentValue["MousePosition"] to position it but am not certain how to do this or how to get it to disappear.

1 Answer
1

Both solutions are undocumented but I don't think they will go away. Menu/MenuItem are used internally for a long time and AttachedCell is a relatively new concept but many of new features use it. E.g. DateSetter[], suggestion toolbar, image tools, message stack preview, etc.

ContextMenu

Quite out of the box. One needs to remember to use KernelExecute for procedures which can not be performed by the FrontEnd. Also, MenuEvaluator must be set to Automatic or a specific name of the Kernel you want to use. Otherwise the FrontEnd will try to run the procedure and it will probably fail returning 'unknown packet dialog'. Why both are needed? I don't know.

$\begingroup$Not on this site often enough anymore. Only just read this. Style[...,ContextMenu...] is a good find. I've had to place a ContextMenu.tr file in the FrontEnd>TextResources path to customise the context menu but this is potentially a much better solution$\endgroup$
– Mike HoneychurchJan 6 at 22:21

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.