Hi Djon!
So we dump the “cover” element idea - way too clunky for your situation.
This concept OneClickOnly_JHSv1.hype.zip (13.9 KB) is based on (2) assumptions:
1) The simplest solution possible for this particular need.
The code manipulates the element that is clicked on - which of course is a button with the corresponding “On Mouse Click” event trigger. So no need for a set-up… i.e. creating IDs or classes for the buttons - a time waster given the number of buttons you have.
Also, no matter how many buttons (or few) it works. Flexible layouts, etc. do not matter. It is a self-adjusting schema (my favorite kind!).
2) The button(s) will be permanently disabled for the duration of the scene.
…Additionally, I wanted to give the kids a visual feedback loop.
Here is the code:
function oneClick(hypeDocument; element; event) {
if (element.style.opacity == 1) {
// put your code here for the button
element.style.opacity = .5;
}
}
Demo here.
What this code does is:
The first time the button is clicked ( button opacity of 100%, or “1” in the code above) it executes the code you wish (right answer, wrong answer). Then the button is set to 50% opacity (or “.5” in the code above), which is typical behavior for a disabled element such as a button. You can make the opacity whatever You want, so long as it is not 100%.
Clicking on the button again results in the code not executing because the opacity of the element is no longer 100% (“1”). This opacity change will give feedback to the kids. They may not get it immediately, but after a few times they should realize the button is disabled~stops working when it fades.
Once again the enigma that is JavaScript displays its complete lack of imagination. In HyperTalk all you had to do was set an element to “disabled” (no “if’s” or “if else’s” required). You could easily send messages (code) to any target, and on and on. What a failure to serve JavaScript’s intended core audience (as exemplified by the questions on this Forum) - or may be not; perhaps JavaScript is deliberately designed to be a separator (designer clowns not need apply) - if so it is hitting its quota of mystery & confusion - as usual. Javascript is not a clear natural and elegant language - it is a cluttered~grafted mongrel expression. Apparently no one notices the ingenue has no clothes.
No reason to get excited, the Thief he kindly spoke, “There are many here among us who feel that Life is but a Joke.”