Canvas MouseMove vs. Canvas TouchMove

0
0

Hi,

I have a problem finding the position when using TouchMove. On MouseMove the position is retruned by e.X and e.Y

Private Sub Canvas1_MouseMove(sender As Object, e As MouseEventArgs) Handles Canvas1.MouseMove
If Draw = True Then
CanvasDraw(e.X, e.Y)
Canvas1.Stroke()
Canvas1.LineWidth = 1
Canvas1.LineCap = CanvasLineCap.Round
End If
End Sub

But on TouchMove e. does not return X and Y but according to the documentation e.Locations

Private Sub Canvas1_TouchMove(sender As Object, e As TouchEventArgs) Handles Canvas1.TouchMove
If Draw = True Then
‘Dim wPoint As Point = e.Locations
‘CanvasDraw(x, y)
Canvas1.Stroke()
Canvas1.LineWidth = 1
Canvas1.LineCap = CanvasLineCap.Round
End If
End Sub

I can’t find out how to convert e.Locations to X and Y coordinates……

Any help would be highly appreciated 🙂

Regards,

Wim

 

 

 

 

 

 

 

 

 

  • You must to post comments
0
0

Gracias, ?

  • You must to post comments
0
0

Hi Wim,

The Locations property is an array of Point (see TouchEventArgs on our API Documentation website), the difference between MouseMove and TouchMove is that the MouseMove event is fired whenever you move your mouse pointer on the browser, wheras the TouchMove would only move if you press and hold the right click of your mouse or physically touch the browser area with a touchscreen.

You can loop through the Locations array and draw your Canvas from the exposed X and Y properties as you would normally on the MouseMove event.

Something along the lines of the following code:

For i As Integer = 0 To e.Locations.Length - 1
CanvasDraw(e.Locations(i).X, e.Locations(i).Y)
Next

HTH,
Alaa

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.