With the concept of user responsiveness in mind, I’ve tinkered a couple of small apps that are supposed to be eh… responsive, i.e. calculating without having to press enter.
They all rely on InputField
with ContinuousAction
and shall only accept numbers and decimal points.
Code snippet as an example:
field1 = 1;
Grid[{{"Input a number"}, {InputField[Dynamic[field1, (field1 = #) &],
Number, ContinuousAction -> True]}}]
Everything works except when trying to write 1.01
since it halts at the lonely zero which isn’t considered a Number
.
Question:
So my question is, how to make InputField
accept a lonely zero after the decimal point as a number while continually evaluating the users every keystroke.
Edit:
The final goal is to get a quick and responsive CDF. I believe true ContinuousAction
will open up for a lot of small useful applications.
Number
fields are allowed. If you are not going to put it in CDF I'd work with strings $\endgroup$Expression
instead ofNumber
. While you could useString
you will need to convert to be able to use the string number. $\endgroup$ContinuousAction -> True
is that the input1.0
is immediately converted to a number and displayed, the number being the real number one. The number one is displayed automatically as1.
, which removes the0
from theInputField
. I seriously doubt there is a way to hackInputField
in a way that it will work in CDF (or that there is any way at all). - [Should this be an answer?] $\endgroup$