Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is the bit of code causing me issues:

   ActionMenu["Set x", {"x = 1" :> (x = 1;)}, Enabled -> True], 
  {"MouseClicked" :> (nothing++)}]], Dynamic[x]}

No matter how hard I try to click the ActionMenu does not open at all.

Removing the {"MouseClicked" :> (nothing++)} allows to open the ActionMenu:

   ActionMenu["Set x", {"x = 1" :> (x = 1;)}, Enabled -> True], 
  {}]], Dynamic[x]}

The aim of the code would be to Enable/Disable the ActionMenu after x = 1 is clicked in this example.

What am I doing wrong in the first bit of code?

share|improve this question
DynamicModule[{x}, {EventHandler[ ActionMenu["Set x", {"x = 1" :> (x = 1;)}, Enabled -> Dynamic[x =!= 1]]], Dynamic[x]}] Simple, but not sure if this is what you want – Dr. belisarius Dec 22 '13 at 18:01
up vote 3 down vote accepted

Add PassEventsDown -> True:

{DynamicModule[{nothing = 0}, 
   ActionMenu["Set x", {"x = 1" :> (x = 1;)}, 
    Enabled -> True], {"MouseClicked" :> (nothing++)}, 
   PassEventsDown -> True]], Dynamic[x]}
share|improve this answer
I forgot the PassEventsDown option... It's so natural... – Silvia Dec 22 '13 at 18:00
Thanks @ both of you. MichaelE2 strictly replies the "why it does not open" question and Silvia replies the "how to disable after one click" question. Since the main issue was to answer "why it does not open anymore" I've accepted this answer. But once again, thanks for you two :) – Öskå Dec 22 '13 at 18:37

Is this what you want?

{DynamicModule[{flag = True},
               ActionMenu["Set x", {"x = 1" :> (
                                                flag = Not@flag;
                                                x = 1;)},
                Enabled -> Dynamic[flag]

The EventHandler will take whatever it wraps around as mouse event trigger, and I think the "MouseClicked" event is hijacked by it so ActionMenu doesn't see the event.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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