5
$\begingroup$

I have a Raspberry Pi 3 with Mathematica 10.3. The following code does not work properly:

schwE = 0.5;
    DialogInput[
     DialogNotebook[{TextCell["Type in new value if needed"], "ee", 
       InputField[Dynamic[schwE], Number], 
       Button["Proceed", DialogReturn[schwE]]}]]

It is supposed to output the number you insert in the window. It works fine on my Windows version of Mathematica. On the Pi it only works if more than one digit (except 0) after the comma is entered. So with 0.30 ist does not work. With 0.31 it works. Can someone confirm it? Is it a bug or poor programming from my side?

$\endgroup$
  • $\begingroup$ FWIW I get the undesired behavior if I execute your code in v9 on Windows as well. Wrapping the whole thing in a DynamicModule[{schwE=0.5},DialogInput..... makes it work in v9, but not on the RPi $\endgroup$ – bobthechemist Apr 22 '16 at 13:52
  • $\begingroup$ Please see the comment I left on my answer below. If I run your code in a fresh notebook, press and hold the Proceed button for about a second, I get the desired response. $\endgroup$ – bobthechemist Apr 22 '16 at 16:42
4
$\begingroup$

I think this is a bug in the RPi version of the software. Consider the following code:

DialogInput[{InputField[Dynamic@x], Dynamic@x, 
  Button["ok", DialogReturn[x]]}]

In v9 on Windows, you can see that that x is updated right before the dialog box closes.

enter image description here

The same code on the RPi does not result in an updated value

enter image description here

It seems as if the RPi version of DialogReturn[] does not issue an Enter key (which InputField needs to update the value) whereas the Windows version does). Pressing enter while in the Inputfield on the Raspberry Pi, and then pressing the OK button returns the value.

I'm still thinking about a workaround that doesn't require you to ask the user to press Enter BEFORE closing the dialog box.

$\endgroup$
  • $\begingroup$ does it work on your Pi if you enter more than one significant digit after the comma? Does any other Dynamic work on your Pi? $\endgroup$ – Eisbär Apr 22 '16 at 16:06
  • $\begingroup$ @Eisbär the code above works with multiple digits to the right of the decimal point (I'm not using a german locale, so I can't test if local use of comma vs. point is part of the issue). The key is that pressing <kbd>Enter</kbd> while in the Inputfield is required to register the change in the value. $\endgroup$ – bobthechemist Apr 22 '16 at 16:10
  • $\begingroup$ @Eisbär, can you try something for me please - In a new notebook, fresh kernel, execute the code in this answer. Change the value to 0.3 and press and hold the Proceed button for about a second. Then see if you can get the correct output for 0.31, 0.311, etc with the same process (click and hold the button for about a second). On my system, the time between mouse down/mouse up events appears to influence the evaluation of the dialog box. $\endgroup$ – bobthechemist Apr 22 '16 at 16:36
  • $\begingroup$ I can confirm this. A short click does not update x. However, hitting enter after the entry and then clicking the button would be the remedy. I have to search for a different version of this code. $\endgroup$ – Eisbär Apr 25 '16 at 9:56

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.