Copy link to clipboard
Copied
Hi,
I've got a single checkbox assigned to the field EnableFullScreen. The JavaScript action that handles the checkbox is as follows:
if(EnableFullScreen.isBoxChecked(0) == true)
app.fs.isFullScreen = true;
else
app.fs.isFullScreen = false;
The above code is executed on a Mouse Down event.
When the checkbox is set, I want my PDF to be fullscreen. When the checkbox is not set, I don't want my PDF to be fullscreen.
The code above is doing the opposite of this. Not checked = fullscreen, checked = not fullscreen.
It is behaving like, when I evaluate isBoxChecked(0), the checkbox isn't actually checked yet. Hence, my question about when setting a checkbox actually takes effect relative to the code which is executed in response to the Mouse Down event. If I check a checkbox, should isBoxChecked(0) already be true when I get to the above Mouse Down JavaScript for that checkbox?
Or is there some delay in actually setting the checkbox such that, when the above code is executed, the checkbox won't actually be checked yet?
Thanks for your help with this.
Dave
Replace your code with this:
app.fs.isFullScreen = (event.target.value!="Off");
Copy link to clipboard
Copied
You test the old value of the checkbox.
Copy link to clipboard
Copied
Hi Bernd -- Thanks for your reply.
Your answer certainly explains what's going on. Is there any way, once I get to my JavaScript action code, to test the current value?
Or do I just need to re-design my code to reflect that I'm testing the old value? This would be quite trivial, but from a software design perspective, I would rather be testing the current value if I could. For example, if I test isBoxChecked a SECOND time in my JavaScript action code, would this possibly check the current value?
Thanks again.
Dave
Copy link to clipboard
Copied
Replace your code with this:
app.fs.isFullScreen = (event.target.value!="Off");
Copy link to clipboard
Copied
I tried your code but the checkbox was still reversed. For example, it was not in full screen mode when the checkbox was checked.
Without knowing what your code is doing and not having time at 3:00 AM this morning (US time) to try to figure it out, I tried replacing your "!=" code with "==", and that seemed to fix it.
I'm signing off now, perhaps you can let me know if my change would be expected to fix it or if my change might be sub-optimal in some manner.
I'll check back in the morning. In the meantime, I'll mark your answer above as the "Correct Answer" since it's working now.
Thanks again for your help, I always appreciate it.
Dave
Copy link to clipboard
Copied
If you want the full screen mode to start when the box is ticked and stop when it is un-ticked then my code will do that.
If you want it to work the other way around, your version will work.
Copy link to clipboard
Copied
You can use this:
app.fs.isFullScreen = !EnableFullScreen.isBoxChecked(0);
Copy link to clipboard
Copied
Hi Bernd,
I think we're both expecting the same thing -- full screen should begin when the Full Screen checkbox is checked and full screen should be reduced to non-full screen when the check is removed from the Full Screen checkbox.
I double-checked (no pun intended) and I did have to make the change to your code (switching "!=" to "==") in order to have it work as we both believe it should work.
However, I just switched to your code immediately above and, with that code, it behaves correctly. As I understand it, this code will check the checkbox value BEFORE it's changed and then toggle the value. So, if it finds the checkbox unchecked (isBoxChecked == false), it will set isFullScreen = true and then the checkbox will become checked after that.
Thanks again for your help, you're a great resource on this forum.
Dave
Copy link to clipboard
Copied
DHeadrick wrote
...
However, I just switched to your code immediately above and, with that code, it behaves correctly. As I understand it, this code will check the checkbox value BEFORE it's changed and then toggle the value. So, if it finds the checkbox unchecked (isBoxChecked == false), it will set isFullScreen = true and then the checkbox will become checked after that.
...
Correct.