Help! Mouse control outside of canvas..

BlitzPlus Forums/BlitzPlus Programming/Help! Mouse control outside of canvas..

MOUSE CONTROL OUTSIDE OF CANVAS

Please run the code below.
When the mouse pointer exits the canvas, the rectangle doesn't follow the pointer anymore.
This is because player\x# and player\y# gets its coordinates from MouseX(canvas)/MouseY(canvas).
What I'm after, is when the pointer exits, for example, on the right side, the rectangle stops at the canvas' right edge, no matter how far the pointer goes beyond the canvas, but you'll still be able to control the Y axis, player\y#...

I've just started messing with the GUI side of B+, and this problem's been bugging me since sunday!

Anyone got the answer to this? Cheers :)

winw=320:winh=240
Global window=CreateWindow( "test...",200,ClientHeight(Desktop() )/2-winh/2,winw,winh,Desktop(),3+32 )
Global canvas=CreateCanvas( 0,0,320,240,window )

SetGadgetLayout canvas,1,1,1,1;set canvas attributes to stretch
SetGadgetShape window,ClientWidth( Desktop() )/2-400/2,ClientHeight( Desktop() )/2-480/2,400,480;resize canvas, 320x240 to 400x480
ActivateGadget canvas
SetBuffer CanvasBuffer( canvas )

Type player1
	Field x#
	Field y#
End Type

player.player1=New player1
player\x#=160
player\y#=180

MoveMouse 160,120,canvas

;----------------------------------------------------------------------------------------------------
While Not KeyHit( 1 )
	Cls
	id=PeekEvent()
	If id<>0 Then
		If id=$803 Then Exit
		FlushEvents()
	EndIf
	Gosub updateplayer
	FlipCanvas canvas
Wend
End
;----------------------------------------------------------------------------------------------------

.updateplayer
For player.player1=Each player1
		player\x# =  MouseX(canvas)
		player\y# =  MouseY(canvas)
	Rect player\x#-8,player\y#-8,16,16
Next
Return