2
$\begingroup$

Why doesn't this code work?

ActionMenu["select an option", {"choose a file" :> 
   FileNameSetter[Dynamic[x]]}]

Is there a way to get FileNameSetter to work inside ActionMenu?

$\endgroup$

1 Answer 1

5
$\begingroup$

two things to consider: FileNameSetter is used to generate a button which then subsequently gets pressed to open a window. When a window opens for you to select a file it is best to use the queued evaluation channel rather than preemptive.

Try this instead:

ActionMenu["select an option", {"choose a file" :> 
   (x=SystemDialogInput["FileOpen"])}, Method -> "Queued"]
$\endgroup$
1
  • $\begingroup$ Thank you for showing me a cleaner way to accomplish what I was after. Much obliged. $\endgroup$
    – Todd Allen
    Dec 21, 2015 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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