2
$\begingroup$

First post on this forum so I apologize if my formatting isn't perfect.

My problem: I'm attempting to pass a list of coordinate pairs as a parameter for a control in manipulate. The goal is to be able to display all the coordinates in a drop down list, the user clicks that coordinate and assigned to the corresponding variable. I know this is all obvious but I just want to be as precise as possible with my dilemma.

Currently when I run the manipulate function the control is displayed as a scroll, which doesn't even work. I tried to use PopUpMenu but was unsuccessful.

This is what I have so far within manipulate:

{{choiceWhite, random, "Vertical moves"},LOptions[Domineering[{1,1}, {1, 2}, {1, 3}, 
{2, 1}, {2, 2}, {2, 3}]]}

Here is some output to show you what the Domineering and LOptions display individually.

enter image description here

As you can see the LOptions function, from what my verbiage tells me, is a list of coordinate pairs and I need to be able to show them like this:

enter image description here

I appreciate any tips or advice anyone can give me.

$\endgroup$
  • $\begingroup$ After fiddling around I was able to accomplish my task by mapping ToString to the List. Thanks! $\endgroup$ – AlecLeonK Feb 21 '16 at 2:38
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Feb 21 '16 at 2:44
1
$\begingroup$

You haven't shown your unsuccessful attempt using PopupMenu. This works:

Manipulate[
 choiceWhite,
 {{choiceWhite, {1, 1}, "Vertical moves"}, 
  PopupMenu[#, {{1, 1}, {1, 2}, {1, 3}}] &}
 ]

So providing LOptions[Domineering[{1,1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}]] returns a list as you have shown then this should work:

Manipulate[
 choiceWhite,
 {{choiceWhite, {1, 1}, "Vertical moves"}, 
  PopupMenu[#, 
    LOptions[
     Domineering[{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}]]] &}
 ]

You may also need to wrap Dynamic around the PopupMenu if LOptions[...] is going to be changing due to some other process. But with scant information in the question impossible to speculate.

Manipulate[
 menu = LOptions[
   Domineering[{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}]];
 choiceWhite,
 {{choiceWhite, First[menu], "Vertical moves"}, 
  Dynamic[PopupMenu[#, menu], TrackedSymbols :> {menu}] &}
 ]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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