Klept02: many thanks!
Based on your example, I wrote a mouseType to save the status of the mouse.
Based on your example, I wrote a mouseType to save the status of the mouse.
' createcanvas.bmx Strict Global GAME_WIDTH=320 Global GAME_HEIGHT=240 ' create a centered window with client size GAME_WIDTH,GAME_HEIGHT Local wx=(ClientWidth(Desktop())-GAME_WIDTH)/2 Local wy=(ClientHeight(Desktop())-GAME_HEIGHT)/2 Local window:TGadget=CreateWindow("My Canvas",wx,wy,GAME_WIDTH,GAME_HEIGHT,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS) ' create a canvas for our game Local canvas:TGadget=CreateCanvas(0,0,320,240,window) Local mouse:TMouse = New TMouse ' create an update timer CreateTimer 60 While WaitEvent() Select EventID() Case EVENT_TIMERTICK RedrawGadget canvas Case EVENT_GADGETPAINT SetGraphics CanvasGraphics(canvas) SetOrigin 160,120 SetLineWidth 5 Cls DrawText String(mouse.getX()) +","+String(mouse.getY())+ "-->"+String(mouse.leftMouseDown()), 10,10 Local t=MilliSecs() DrawLine 0,0,120*Cos(t),120*Sin(t) DrawLine 0,0,80*Cos(t/60),80*Sin(t/60) Flip Case EVENT_MOUSEMOVE mouse.setMousePos(EventX(), EventY()) Case EVENT_MOUSEDOWN mouse.doMouseDown(EventData()) Case EVENT_MOUSEUP mouse.doMouseUp(EventData()) Case EVENT_WINDOWCLOSE FreeGadget canvas End Case EVENT_APPTERMINATE End End Select Wend Type TMouse Field piX% = 0 Field piY% = 0 Field pbLeftMouseDown:Byte = False Field pbRightMouseDown:Byte = False Method setMousePos(x%, y%) piX = x piY = y End Method Method getX%() Return piX End Method Method getY%() Return piY End Method Method doMouseDown(btn%) Select btn Case 1 pbLeftMouseDown = True Case 2 pbRightMouseDown = True End Select End Method Method doMouseUp(btn%) Select btn Case 1 pbLeftMouseDown = False Case 2 pbRightMouseDown = False End Select End Method Method leftMouseDown() Return pbLeftMouseDown End Method Method rightMouseDown() Return pbRightMouseDown End Method End Type