'handler demo

'-----------------------------------------------------------------------------------------------
'class rectangle with 4 properties

common rect[ 256,3 ]

'state=0 'properties 0 is state 0=unset 1=set
'x=1 'properties 1 is x position
'y=2 'properties 2 is y position
'col=3 'properties 3 is color

'method
sub rect_draw(r)
     ink(rect[r,3])
     box(rect[r,1]-3,rect[r,2]-3,rect[r,1]+3,rect[r,2]+3)
end sub

sub rect_clear(r)
     ink(paper)
     box(rect[r,1]-3,rect[r,2]-3,rect[r,1]+3,rect[r,2]+3)
end sub

sub rect_set(r,col,x,y)
    rect[r,0]=0
    rect[r,1]=x
    rect[r,2]=y
    rect[r,3]=col
end sub

function rect_check(r)
    if bmouse=1 then
	if mousezone(rect[r,1]-3,rect[r,2]-3,6,6)or rect[r,0]=1 then
	    rect_clear(r)
	    rect[r,1]=xmouse
	    rect[r,2]=ymouse
	    rect_draw(r)
	    waitvbl
	    rect[r,0]=1
	end if
    else
	rect[r,0]=0
    end if
    return rect[r,0]
end function
'------------------------------------------------------------------------------------------------
