Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a Manipulate, one can specific the type of an individual control like so:

Manipulate[v, {v, Red, ColorSetter}]

I tried to do the same with FileNameSetter, i.e.

Manipulate[v, {v, "no file chosen", FileNameSetter}]

but that doesn't work, and the control is a slider. I can work around the issue like so:

Manipulate[{v, FileNameSetter[Dynamic[v]]}, {v, "no file chosen"}, 
  ControlType -> None]

but I would rather understand why my second example above doesn’t behave as expected. Do you have any idea?

share|improve this question
up vote 7 down vote accepted

Manipulate does not directly support a control type called "FileNameSetter", but fortunately it is possible to use custom controls (both in Manipulate and other functions), as described e.g. in the Control documentation:

{u,func}        an arbitrary control from a function

The trick to getting it working is that func must be a pure function. This is mentioned in the Advanced Manipulate Tutorial, in the section showing how to build a custom slider.

So, somewhat unusually, Control[{v, FileNameSetter}] will not work, but Control[{v, FileNameSetter[##]&}] will. The equivalent construction using Manipulate would be:

Manipulate[v, {{v, "none"}, FileNameSetter[##] &}]

(Of course things would be much simpler if Manipulate would just support FileNameSetter directly as it does ColorSetter)

share|improve this answer
Oh, you are good… So, let me get this straight: using FileNameSetter does not work, but FileNameSetter[##]& does? (as does FileNameSetter[#]&) How crazy! – F'x Nov 9 '12 at 16:10
@F'x Yes, it's quite nasty ... a function should be a function regardless of which kind it is. It's just not nice that only a pure function works in this case ... but I can understand why: how would one detect in a reasonable way if a symbol can be considered a function or not? – Szabolcs Nov 9 '12 at 16:29
It seems to me that the documentation is misleading because if you follow the {u,func} pattern where u is a variable you might think Manipulate[v, {v, FileNameSetter[##] &}] would work and it does, after a fashion...the variable v is initialized to func and thereafter takes the expected value. – fairflow Nov 13 '14 at 10:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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