Use this thread to discuss your questions and comments about how to run the lesson.
Question about App Lab –
When we use getText to bring the question down into the answer field, that string will vanish if the user clicks anywhere in the answer field…wait, if the user clicks ANYWHERE.
Is that a known issue?
Can you send a project with an example of what you are talking about?
So if I enter a question and hit Enter, it shows up in the response box. As soon as i click anywhere on the screen, the text disappears from that response box. (I tried to use the Snipping tool, but couldn’t because I wasn’t able to click!)
That definitely is confusing behavior. What’s happening is when the user presses enter and the question text has changed, the code sets the question field to be an empty string. So now the question field has changed again (from whatever text it had before to the empty string), meaning the onEvent code gets fired again if you click outside the question field (or were to press Enter again). Then that code sets the text in the answer area to include what’s in your question field, which is currently empty, giving the appearance that text is vanishing.
One idea is to wrap the code inside the callback function in an if statement, so that the code is only run if the question field isn’t empty. The other thing you can do is listen to a keydown event instead of a change event. Only execute the code if the enter key is pressed (event.key == “Enter”).
Hopefully that makes sense!
Certainly does! I’ll pass it along to my student who noticed the issue – he’s got a bit of coding experience already, so this kind of thing is right up his alley.
Thank you for taking the time to respond so thoroughly!