mouse position inside canvas

BlitzMax Forums/BlitzMax GUI Programming/mouse position inside canvas

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

How to determine dx and dy ? (how many pixels mouse moved from last position) Where reinit dx=0,dy=0 when the mouse doesn't move ? Thanks to help me !
Strict


Global Win2:TGadget   = CreateWindow("",(GadgetWidth(Desktop())-540)/2,(GadgetHeight(Desktop())-650)/2,540,650,Null,WINDOW_MENU|WINDOW_TITLEBAR)
Global Panel_choix_map : Tgadget = CreatePanel (0,0,700,40, Win2)
Global Canvas2:TGadget= CreateCanvas(10,50,512,512,Win2) 

	

' -------------------------------------------------------------------------------------------

Global mx, my
Global dx, dy

Global Timer:TTimer = CreateTimer(60)

While WaitEvent()

	
	Select EventID()
	
		Case EVENT_MOUSEMOVE
		
			dx = mx - EventX()
			dy = my = EventY()
		
			mx = EventX()
			my = EventY()
			
	
		Case EVENT_TIMERTICK
		
			SetGraphics CanvasGraphics(Canvas2)
			Cls
			SetColor 255,255,255
			
			DrawOval mx-2,my-2,2,2
			DrawText String Int(mx) + "," + String (Int(my)), mx,my
			DrawText "dx=" + String Int(dx) + ",dy=" + String (Int(dy)), mx,my + 16

			
			Flip
		
			
		Case EVENT_WINDOWCLOSE
			Exit
			
	
	End Select
Wend