0

I'm using Google closure library and registering for click and mouse move event. I get the click event, however Mouse move event doesn't come. This is observed for Chrome browser, get the same event in Firefox

<canvas id='canvas1'  width="512px" height="512px" style='top:0px;right:0px;'  > </canvas>

MyTest.virtualCanvas = function(){
    this.destCanvas = document.getElementById('canvas1');
    this.destCtx = this.destCanvas.getContext('2d');
    
    
    this.getCallBackFn = this.highContrastFn.bind(this);
    this.mouseMoveBackFn = this.mouseMoveCB.bind(this);
    
    goog.events.listen(this.destCanvas, goog.events.EventType.CLICK, this.getCallBackFn);
    goog.events.listen(this.destCanvas, goog.events.EventType.MOUSEMOVE, this.mouseMoveBackFn);
    
    
};



MyTest.virtualCanvas.prototype.mouseMoveCB = function(evt){
        var x = evt.offsetX;
        var y = evt.offsetY;

}

MyTest.virtualCanvas.prototype.highContrastFn = function(evt){
    var x = evt.offsetX;
    var y = evt.offsetY;
                
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Abhinav
  • 191
  • 1
  • 3
  • 16

1 Answers1

0

I'm not sure why above didn't work. However, if I use bind method function from google closure, it works

goog.events.listen(this.destCanvas, goog.events.EventType.MOUSEMOVE,goog.bind(this.mouseMoveCB, this) )
Abhinav
  • 191
  • 1
  • 3
  • 16