Message Boards Message Boards

GROUPS:

Design a Menu with the same behavior as the Mathematica FrontEnd Menu?

Posted 11 months ago
558 Views
|
0 Replies
|
0 Total Likes
|

Hi, I'm trying to design a Menu like the Mathematica FrontEnd:

Current behavior:

If "MouseOver PopUp" then it changes the color from gray to blue. If "MouseExited PopUp" then it changes the color from blue to gray. If "Clicked PopUp" then PopUp opens ... But if I move the mouse over another PopUp the latter does not turn blue until "Clicked PopUp" again: fail.

I would like this behavior:

When "Clicked PopUp" then the corresponding PopUp opens, and when you move the cursor to another PopUp, only this last PopUp opens -if you had one open before. Same as in the FrontEnd Menu of Mathematica.

Do you have any idea how to achieve this behavior?

Thank you. Example:

OneMenu[Head_, actions_, options___] := 
  DynamicModule[{x = Unique["x"], listActions, HeadActions, event},

   event =.;
   listActions = HeadActions = Table[Delimiter, {Length@actions}];

   Do[
    HeadActions[[i]] = actions[[i]];
    listActions[[i]] = actions[[i]];

    If[HeadActions[[i]] === 
      Delimiter, (HeadActions[[i]] = Delimiter), (HeadActions[[i]] = 
       actions[[i, 1]])];

    If[listActions[[i]] == 
      Delimiter, (listActions[[i]] = 
       ToExpression["Delimiter\[RuleDelayed]Null"])];

    , {i, 1, Length@actions}];


   DynamicWrapper[
    Mouseover[
     PopupMenu[
      Dynamic[Refresh[x, 
        TrackedSymbols :> {}], (event =.; event = #) &], HeadActions, 
      Head, options, Background -> GrayLevel[0.90]], 
     PopupMenu[
      Dynamic[Refresh[x, 
        TrackedSymbols :> {}], (event =.; event = #) &], HeadActions, 
      Head, options, Background -> LightBlue]]

    , Refresh[event /. listActions, TrackedSymbols :> {event}]

    , SynchronousUpdating -> False]

   ];

Row[{OneMenu[
   "File", {"Save" :> Print[4!], 
    "Save as..." :> (Print[1!]; Pause[2]; Print[7!]), Delimiter, 
    "Hello¡" :> Print["Hola¡"]}, Appearance -> "Frameless", 
   FrameMargins -> {{3, 3}, {0, 0}}, ContentPadding -> False, 
   ImageSize -> {Automatic, Automatic}], 
  OneMenu["Edition", {"Save" :> Print[4!], 
    "Save as..." :> (Print[1!]; Pause[2]; Print[7!]), Delimiter, 
    "Hello¡" :> Print["Hola¡"]}, Appearance -> "Frameless", 
   FrameMargins -> {{3, 3}, {0, 0}}, ContentPadding -> False, 
   ImageSize -> {Automatic, Automatic}], 
  OneMenu["Operations", {"Sum 1+1" :> Print[(1 + 1)], 
    ",,," :> (Print[19!]; Print[7!]), Delimiter, 
    "Book¡" :> Print["Libro¡"]}, Appearance -> "Frameless", 
   FrameMargins -> {{3, 3}, {0, 0}}, ContentPadding -> False, 
   ImageSize -> {Automatic, Automatic}], 
  OneMenu["Help", {"." :> Print[1!], ".." :> (Print[2!];), Delimiter, 
    "Bye¡" :> Print["Adios¡"]}, Appearance -> "Frameless", 
   FrameMargins -> {{3, 3}, {0, 0}}, ContentPadding -> False, 
   ImageSize -> {Automatic, Automatic}]}]
Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract