Skip to main content
Inspiring
April 26, 2016
Answered

addEventListener for check box

  • April 26, 2016
  • 1 reply
  • 733 views

Hi

I have a check box. I would like to set up an eventListener for it.

This works:

cb.onClick = function()

{

     alert("clicked");

}

This don't:

cb.addEventListener("click", cbClick);

function cbClick()

{

     alert("clicked");

}

Why not? I have used the addEventListener method for many other components.

Thanks,

Jakob

This topic has been closed for replies.
Correct answer UQg

"click" is the correct word but, since CC versions, everything that behaves similarly to a button (with or without a value, ie basic buttons, iconbuttons, checkboxes, radiobuttons, etc) do not respond to the events "mouseup" and "click". Only mousedown, mouseover or mouseout for this kind of widgets. It has been silently disabled.

Xavier

1 reply

Inspiring
April 27, 2016

Just realized. This is also the case for the iconbutton and button component.

This works:

button.addEventListener("mouseover", buttonMouseOver);function buttonMouseOver()

{

alert("over");

}

This do not:

button.addEventListener("click", buttonClick);

function buttonMouseOver()

{

alert("clicked");

}

So maybe it is the click event which is different? Is "click" the correct word to use?

UQg
UQgCorrect answer
Brainiac
April 28, 2016

"click" is the correct word but, since CC versions, everything that behaves similarly to a button (with or without a value, ie basic buttons, iconbuttons, checkboxes, radiobuttons, etc) do not respond to the events "mouseup" and "click". Only mousedown, mouseover or mouseout for this kind of widgets. It has been silently disabled.

Xavier

Inspiring
April 28, 2016

Thank you very much for answering.

But Adobe, I think that is ridiculous. But I guess I will have to live with ugly code then.