diff --git a/js/gui/Canvas.js b/js/gui/Canvas.js index 36ac2fc..8180e93 100644 --- a/js/gui/Canvas.js +++ b/js/gui/Canvas.js @@ -256,6 +256,7 @@ dojo.declare("gui.Canvas", [dijit._Widget], { _touchstart: function (event) { this._active = true; + this._touch_prev = event; // We need to add the relative placement informatoin to all touch events for(var i = 0; i < event.touches.length; ++i) { @@ -280,6 +281,11 @@ dojo.declare("gui.Canvas", [dijit._Widget], { _touchend: function (event) { this._active = false; + if( event.touches.length == 0 ) { + // Use last active position + event = this._touch_prev; + } + for(var i = 0; i < event.touches.length; ++i) { var x = event.touches[i].pageX - this._placementX(); var y = event.touches[i].pageY - this._placementY(); @@ -303,6 +309,7 @@ dojo.declare("gui.Canvas", [dijit._Widget], { }, _touchmove: function (event) { + this._touch_prev = event; for(var i = 0; i < event.touches.length; ++i) { var x = event.touches[i].pageX - this._placementX(); var y = event.touches[i].pageY - this._placementY(); diff --git a/js/shared/DSRV.js b/js/shared/DSRV.js index e7b06a1..5915218 100644 --- a/js/shared/DSRV.js +++ b/js/shared/DSRV.js @@ -331,6 +331,52 @@ DSRV.prototype = { this.m_manipulator.setStateNone( x, y ); //this.pushMatrices(); }, + + touchStartEvent: function (event) + { + if( event.touches.length == 1 ) { + event.button = 0; + this.mousePressEvent(event); + } + else if( event.touches.length == 2 ) { + event.button = 2; + this.mousePressEvent(event); + } + else if( event.touches.length == 3 ) { + event.button = 1; + this.mousePressEvent(event); + } + }, + touchEndEvent: function (event) + { + if( event.touches.length == 1 ) { + event.button = 0; + this.mouseReleaseEvent(event); + } + else if( event.touches.length == 2 ) { + event.button = 2; + this.mouseReleaseEvent(event); + } + else if( event.touches.length == 3 ) { + event.button = 1; + this.mouseReleaseEvent(event); + } + }, + touchMoveEvent: function (event) + { + if( event.touches.length == 1 ) { + event.button = 0; + this.mouseMoveEvent(event); + } + else if(event.touches.length == 2) { + event.button = 2; + this.mouseMoveEvent(event); + } + else if(event.touches.length == 3) { + event.button = 1; + this.mouseMoveEvent(event); + } + }, pushMatrices: function() { var viewer = this.m_model.getElementValue( this.m_key ); viewer.updateElement( "modelview", this.m_manipulator.modelviewMatrix() );