Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm looking to create dynamic menus with multiple options, and would allow multiple selections.

For example, mousing over an object (let's say a black circle of rad 1), a menu would popup at MousePosition[] with two options of "red" and "5". Selecting red would create a new circle, red with rad1, and selecting both would give a red circle of rad 5.

How would I create temporary/dynamic menus similar to the standard right-click (disappears after clicking away), except with multi-selection?

Edit: I got carried away with my end-goal example. All I am wondering is if Panel is the correct function to use here with multiple checkboxes (the documentation examples did not have what I expected).

screenshot

share|improve this question
    
Have a look at this thread, this may get you started. If I have time, I will port that answer here as an answer. –  Leonid Shifrin Aug 21 '12 at 16:32
    
THanks Leonid, I'll look through that –  Twoday Aug 21 '12 at 16:35
add comment

1 Answer 1

up vote 1 down vote accepted

Something like:

Panel@DynamicModule[{color = Gray, radius = 1, ww = {}},
Mouseover[
   Graphics[{Dynamic@color, Disk[{0, 0}, Dynamic@radius], Gray, Circle[{0, 0}, 3]}],
   Dynamic[Panel[CheckboxBar[
      Dynamic[ww, {(ww = #; radius = If[MemberQ[ww, 1], 2, 1]; 
              color = If[MemberQ[ww, 2], Red, Gray]) &}],
      {1 -> "radius = 2", Delimiter, 2 -> "color = Red"},
   Appearance -> "Vertical", Appearance -> Small]]],
   ImageSize -> All]]

Screenshots:

view when mouse is over the panel:

enter image description here

views when mouse is off the panel:

enter image description here

enter image description here

enter image description here

share|improve this answer
    
Ahhh beautiful ~~Thank you. Could you explain why there are two Panels in your code? I believe the second Panel creates the panel with the checkboxbar, but what does the first line (Panel@DynamicModule) do? edit: oh wait, one of them makes the circle...? –  Twoday Aug 21 '12 at 22:21
    
@Twoday, the outer panel is not essential. I used it to get the screenshots -- to crop the prt-scr image to appropriate size. –  kguler Aug 21 '12 at 22:36
add comment

Your Answer

 
discard

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.