0

I have a listener on canvas for whenever I click on it. At certain moments (like when a checkbox is checked) I want to disable that listener and make clicking on it do nothing. How do I do this?

jQuery is allowed.

2
Contributors
5
Replies
22
Views
4 Years
Discussion Span
Last Post by riahc3
0

canvas.removeEventListener should work, but only with named functions.

OK and then how do I had it back?

I just had a thought: Would disabling canvas be enough?

0

OK and then how do I had it back?

Not sure what you mean, but if you are adding anonymous functions, you can't remove them (apparently).

Disabling may work, depending on the event I guess.

0

Not sure what you mean, but if you are adding anonymous functions, you can't remove them (apparently).

Disabling may work, depending on the event I guess.

I have this:

handleCanvasMouseDown: function(e){
      this.drawManager.unSelectAllPointsOfTheDrawingThatHasPoints(); 
    },

handling the mouse event on a canvas. A simple if

if it is checked
return false
else if it is not checked
this.drawManager.unSelectAllPointsOfTheDrawingThatHasPoints();

Does not work. It stil continues. And yes, it goes into the checked because a alert does show up.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.