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$
  • $\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$ – Sjoerd C. de Vries Jun 30 '16 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 '16 at 1:33
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

|improve this answer|||||
$\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.