Skip to main content

Hold[Expression] (or similar) in InputField that truly holds the input unmodified


I am trying to design a user interface where the specific form that the user enters in InputFields are left unchanged. For example, if the user puts in a number in scientific notation, it would be really nice for that value in the field to stay the same, even though it is modified internally into a different form. None of the Hold-type functions seem to do what I want (and only Hold[Expression] seems to be an option in InputField anyway).


enter image description here


enter image description here



Any ideas?



Answer



InputField[Dynamic[var], Boxes]

enter image description here


Column[{InputField[Dynamic[var], Boxes], 
Dynamic[var],
Dynamic[RawBoxes @ var],
Dynamic[ToExpression @ var] }]


enter image description here


Comments