1
$\begingroup$

Is it possible to specify a style, e.g., font size, for InputField type controls inside a Manipulate and if so, how?

For example, in the following the BaseStyle option to Manipulate changes the output font size but not the font size of the input fields:

Manipulate[
  y[t] /. First@
      DSolve[{a y''[t] + b y'[t] + c y[t] == r, y[t0] == ic, y'[t0] == icp}, y[t], t],
  {{a, 1}, "a"}, {{b, 1}, "b"}, {{c, 1}, "c"}, {{r, 0}, "r(t)"}, 
  {{t0, 0}, "t0"}, {{ic, 0}, "y[t0]"}, {{icp, 0}, "y'[t0]"}, 
  ControlType -> InputField, BaseStyle -> 16]

I tried the "obvious" way of using, e.g., Style[a] instead of a in the control-variable specification, but that's erroneous.

$\endgroup$
2
$\begingroup$

You have a few syntax errors. Here you have them corrected and an example on how to change each component styling:

Manipulate[
 y[t] /. First@ DSolve[{a y''[t] + b y'[t] + c y[t] == r, y[t0] == ic, y'[t0] == icp}, y[t], t],
 {{a, 1, "a"}},
 {{b, 1, "b"}},
 {{c, 1, "c"}},
 {{r, 0, "r(t)"}},
 {{t0, 0, "t0"}},
 {{ic, 0, "y[t0]"}},
 {{icp, 0, Style["y'[t0]", {16, Red}]}, BaseStyle -> 30},
 ControlType -> InputField, BaseStyle -> {16, Bold}]

Mathem![Mathematica graphics

$\endgroup$
  • $\begingroup$ Actually, and not considering how to change the style of the input fields, I don't think I had any syntax errors except in so far as the field labels are concerned; for that your revised syntax is correct. $\endgroup$ – murray Feb 27 '15 at 4:47
  • $\begingroup$ Works nicely: thanks! (For the record, this was the first answer posted, but it was withdrawn temporarily before I got a chance to accept it and thank its author, @belisarius.) $\endgroup$ – murray Feb 27 '15 at 20:11
1
$\begingroup$

Quick answer

put it as a specification of the controller

Manipulate[x, {{x, 0}, 0, 100, BaseStyle -> FontSize -> 25}, ControlType -> InputField]

enter image description here

Quick notes

  • Nonuniform styles handling is really annoying, one have to always remember what can be inherited and what not or put explicit directives everywhere.

    I asked it already in Are there any rules about style inheritance in Mathematica?

  • Here it is also strange because BaseStyle applies to body of a Manipulate and labels, not to controller even though that Style[InputField[], 25] can inherit FontSize.

$\endgroup$
  • $\begingroup$ thanks, that works perfectly. Since the only style parameter I need to change is the font size, the target of BaseStyle can be simplified a bit: Manipulate[a, {{a, 1, Style["a", 16]}, BaseStyle -> 16}, ControlType -> InputField] $\endgroup$ – murray Feb 27 '15 at 18:31
  • $\begingroup$ I, too, would sure like to see a convincing explanation of when and how styles are inherited. $\endgroup$ – murray Feb 27 '15 at 18:33

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.