2
$\begingroup$

I'm looking to create Dynamic menus with multiple options that would allow multiple selections.

For example, mousing over an object (let's say a black circle of radius 1), a menu would popup at MousePosition[] with two options of "red" and "5". Selecting "red" would create a new circle, red with radius of 1, and selecting both would give a red circle of radius = 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

$\endgroup$
2
  • $\begingroup$ Have a look at this thread, this may get you started. If I have time, I will port that answer here as an answer. $\endgroup$ Aug 21, 2012 at 16:32
  • $\begingroup$ THanks Leonid, I'll look through that $\endgroup$
    – Twoday
    Aug 21, 2012 at 16:35

1 Answer 1

1
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ 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...? $\endgroup$
    – Twoday
    Aug 21, 2012 at 22:21
  • $\begingroup$ @Twoday, the outer panel is not essential. I used it to get the screenshots -- to crop the prt-scr image to appropriate size. $\endgroup$
    – kglr
    Aug 21, 2012 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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