There seems that there have been some change sin the PsychoJS source code since I found the workaround. This made the fix I found to stop working.
After some time trying to figure out what changed and how to solve the problem once more, I found out that the PsychoPy team had solved the problem with the destruction of the Dialogue Boxes. Now it happens automatically when one of the “Ok”, “Cancel” or “X” buttons is pressed.
This made the function … document.getElementById();
… to unusable to get the values typed in the input values. As the Dialogue Box is now destroyed automatically, the function can no longer find the IDs of the input fields.
However, this helped me figure out an other way, which I think is the proper way, of getting the values typed in the input fields. Here is the new working code:
showTextBox = function(text1="", text2="") {
//Create new Dialoge Box
let boxTitle = 'Title of the dialogue box';
let boxFields = {'Label1': text1, 'Label2': text2};
var myBox = psychoJS.gui.DlgFromDict({
dictionary: boxFields,
title: boxTitle
});
//Run the new Dialogue Box
myBox();
//Enable the "OK" button
$("#buttonOk").button("option", "disabled", false);
$("#buttonOk").hide(0, () => { $("#buttonOk").show(); });
//Hide the progress bar
$("#progressbar").hide();
//When "OK" is pressed...
$("#buttonOk").click(function() {
// Variables that will be updated
var Label1_Input = boxFields["Label1"];
var Label2_Input = boxFields["Label2"];
});
//When "CANCEL" is pressed
$("#buttonCancel").click(function() {
});
//When the "X" is pressed to close the box
$(".ui-dialog-titlebar-close").click(function() {
});
}
** Notice that this function cannot return the updated values of the input fields as it finishes running way before the people are able to type something and click on “OK”. The function in charge of updating the value of the variables is a JQuery called when the “OK” button is pressed.