How do I make ActionMenu's menu appear with one mouseclick of the button and disappear with a second consecutive click on the same button? I would like to be able to click on an ActionMenu
in order to inspect the action labels and then click on the ActionMenu
button again to close the menu. I believe this behavior is likely seen in many operating systems. This functionality doesn't appear to be obviously supported within Mathematica's control objects, but I hope I'm wrong.
As my first attempt to get this working, I tried the following hoping that the EventHandler
would re-evaluate the ActionMenu
and set it to the initial view with the menu not visible but this "hacky" attempt didn't yield anything. Here's the code:
EventHandler[ActionMenu["Print Factorials", {"4!" :> Print[4!], "7!" :> Print[7!],
"10!" :> Print[10!]}], {"MouseClicked" :> ActionMenu[
"Print Factorials", {"4!" :> Print[4!], "7!" :> Print[7!],
"10!" :> Print[10!]}]}, PassEventsDown -> True]
I've also tried using Mouseover
to achieve this idiomatic functionality without any luck. Again, here's the code in case this helps:
Mouseover[ActionMenu[
Style["Print Factorials", FontFamily -> "Arial",
FontSize -> 12], {"4!" :> Print[4!], "7!" :> Print[7!],
"10!" :> Print[10!]}, Appearance -> None, Enabled -> False],
ActionMenu[
Style["Print Factorials", FontFamily -> "Arial",
FontSize -> 12], {"4!" :> Print[4!], "7!" :> Print[7!],
"10!" :> Print[10!]}, Appearance -> None]]
PopupMenu
instead of anActionMenu
. $\endgroup$PopupView
is another alternative. $\endgroup$