2
$\begingroup$

For this Control inside Manipulate (using Setter or RadioButton):

Control[{{opt,"A"},{"A","B","C"},Setter}]

Is it possible to make the color of the selection change? So if "A" is selected the button is Blue, while "B" and "C" are black.

I read this post about a Button changing colors when clicked and tried to do something similar for my situation but I couldn't get it to work.

$\endgroup$
2
  • $\begingroup$ I believe your code should be Control[{{opt,"A"},{"A","B","C"}}]. I don't think you can add the Setter part. Control doesn't take options as far as I know, but if you select the setter you can change its background color in the Option Inspector. $\endgroup$ Jun 30, 2016 at 20:17
  • $\begingroup$ Use Control[{{opt, "A"}, {"A", "B", "C"}, ControlType -> Setter}] then in another cell evaluate Dynamic[opt] and observe this second cell as you click on the labels in the Setter $\endgroup$
    – Bob Hanlon
    Jul 1, 2016 at 1:33

1 Answer 1

3
$\begingroup$

The way I read the documentation one can only control the background color of a Setter or SetterBar. That is to say the foreground color is not available to the user.

If you are willing to use buttons, then I think you can accomplish your goal. I used Cyan and Gray rather than Blue and Black for visibility.

Manipulate[
 Column[{
   {opt, colA, colB, colC},

   Row[{
     Button["A", opt = A; colA = Cyan; colB = Gray;
                   colC = Gray, Background -> colA],
     Button["B", opt = B; colA = Gray; colB = Cyan;
                    colC = Gray, Background -> colB],
     Button["C", opt = C; colA = Gray; colB = Gray;
                   colC = Cyan, Background -> colC]
     }]
   }],

 {{opt, A}, ControlType -> None},
 {{colA, Cyan}, ControlType -> None},
 {{colB, Gray}, ControlType -> None},
 {{colC, Gray}, ControlType -> None}
 ]

Mathematica graphics

$\endgroup$

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.