How do I disable mouse clicking on elements?

I’m working on a scene where I have to answer questions that have multiple correct answers and when I answer correctly (or incorrectly) I need to disable further answering of the offered answers.

How to disable mouse clicking on elements?

Can I have an example with a quiz scene?

doc.getElement("Text_Pol").dom.style.pointerEvents = "none"; //not working

switch (e.target.name) {

case 'Text_D':

doc.N_odg = doc.N_odg +1 ;

doc.getElement("Text_P").dom.style.opacity = "0.5";
doc.getElement("Text_P").dom.style.pointerEvents = "none"; //not working

doc.getElement("Text_L").dom.style.opacity = "0.5";
doc.getElement("Text_L").dom.style.pointerEvents = "none"; //not working

doc.getElement("Text_Pol").dom.style.opacity = "0.5";
doc.getElement("Text_L").dom.style.pointerEvents = "none"; //not working

break;

case 'Text_P':

doc.N_odg = doc.N_odg +1 ;

doc.getElement("Text_D").dom.style.opacity = "0.5";
doc.getElement("Text_D").dom.style.pointerEvents = "none"; //not working

doc.getElement("Text_L").dom.style.opacity = "0.5";
doc.getElement("Text_L").dom.style.pointerEvents = "none"; //not working

doc.getElement("Text_Pol").dom.style.opacity = "0.5";
doc.getElement("Text_L").dom.style.pointerEvents = "none"; //not working

break;

case 'Text_L':

doc.T_odg = doc.T_odg + 1;

if (doc.T_odg == 2) {

doc.getElement('Shape_T').show(true);

doc.getElement("Text_D").dom.style.opacity = "0.5";
doc.getElement("Text_D").dom.style.pointerEvents = "none"; //not working

doc.getElement("Text_P").dom.style.opacity = "0.5";
doc.getElement("Text_P").dom.style.pointerEvents = "none"; //not working
}

break;

case 'Text_Pol':

doc.T_odg = doc.T_odg + 1;

if (doc.T_odg == 2) {

doc.getElement('Shape_T').show(true);

doc.getElement("Text_D").dom.style.opacity = "0.5";
doc.getElement("Text_D").dom.style.pointerEvents = "none"; //not working

doc.getElement("Text_P").dom.style.opacity = "0.5";
doc.getElement("Text_P").dom.style.pointerEvents = "none"; //not working

}

break;

}

Hi,

You can use a flag to mark whether the mouse click event has been disabled.
For the element that needs to be disabled, add an event that runs JavaScript first; in that event, if the disable flag is set, call e.stopImmediatePropagation();.

Disable mouse click.saola (10.8 KB)

Hope this helps!

Thanks for the reply.

It works partially, the javascript is executed and I can apply it e.stopImmediatePropagation();