5
$\begingroup$

I am building a model for which the user can enter parameter values. I would like to create a "graphical layout" of the model in which I display several InputField-s to enter the numerical parameters, arranged to be shown at the appropriate x-y-locations in my "graphical layout". However, InputFields appear to become non-editable when part of a Graphics object.

For example, the following works (of course):

InputField[Dynamic[x]]

However, the next command creates an InputField that cannot be accessed, although the dynamic value still correctly updates when you change the InputField created by the previous command:

Graphics[Inset[InputField[Dynamic[x]]]]

How can I place InputFields at specific coordinates in (or on top of) a Graphics?

$\endgroup$
1
  • $\begingroup$ @Nasser Yes, this seems to work. I have tried Graphics[...,Deployed->True], which does not work. Please, put it as an answer, then I can accept. $\endgroup$
    – Thomas
    Aug 2, 2013 at 18:36

2 Answers 2

5
$\begingroup$
Deploy@Graphics[Inset[InputField[Dynamic[x]]]]

Can be used to allow input to a field inside Graphics

$\endgroup$
1
$\begingroup$

Sometimes Text is easier to place.

Deploy @ Graphics[{Circle[], Red, PointSize[Large], 
   Dynamic @ Point[{x, 0}], Text[InputField[Dynamic[x]], {0, 0.8}]}]

Mathematica graphics

By the way, without the Deploy, you can edit the InputField this way. Double-click over the InputField; then double-click again. You should be able to edit the InputField.

Note: Without Deploy the user can edit the graphics, too. Usually, with user interfaces, this undesirable. In such cases you should use Deploy anyway.

$\endgroup$
2
  • 1
    $\begingroup$ Isn't Text implemented as Inset since version 6? You can replace Text with Inset above and it behaves the same. $\endgroup$
    – Mr.Wizard
    Aug 4, 2013 at 3:15
  • $\begingroup$ @Mr.Wizard I did not know that. The docs describe them differently (both arguments and function, which is only said to be "similar"), but, checking out combinations of arguments, they in fact they seem have the same syntax and semantics. Thanks! The docs made Inset harder for me to understand, and I've harbored a prejudice until now. One instance: if the Inset argument opos had been described as well as offset for Text, it would have saved me trouble. The argument size for Inset, omitted in the description for Text, does not always behave how I expect it. $\endgroup$
    – Michael E2
    Aug 4, 2013 at 13:17

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.