%% Mouse Module
module MouseInfo
export GetInfo, Left, Right, Middle, X, Y, OldX, OldY
buttonchoose ("multibutton")
var mX, mY : int := 0
var oldX, oldY : int := 0
var diffX, diffY : int
var button : int
var left, right, middle : int := 0
proc GetInfo
oldX := mX
oldY := mY
mousewhere (mX, mY, button)
diffX := oldX - mX
diffY := oldY - mY
left := (button mod 10)
middle := ((button - left) mod 100)
right := (button - middle - left)
end GetInfo
function Left : boolean
result left = 1
end Left
function Right : boolean
result right = 100
end Right
function Middle : boolean
result middle = 10
end Middle
function X : int
result mX
end X
function Y : int
result mY
end Y
function OldX : int
result oldX
end OldX
function OldY : int
result oldY
end OldY
end MouseInfo
drawfillbox (0,0,maxx,maxy,7)
View.Set ("offscreenonly")
loop
color (0)
colorback(7)
locate (1, 1)
put MouseInfo.X, "][", MouseInfo.Y
locate (2, 1)
put MouseInfo.Left, " - ", MouseInfo.Middle, " - ", MouseInfo.Right
MouseInfo.GetInfo
if MouseInfo.Left then
drawdot (MouseInfo.X, MouseInfo.Y, 9)
drawline (MouseInfo.X, MouseInfo.Y,MouseInfo.OldX, MouseInfo.OldY,9)
end if
if MouseInfo.Middle then
drawdot (MouseInfo.X, MouseInfo.Y, 10)
drawline (MouseInfo.X, MouseInfo.Y,MouseInfo.OldX, MouseInfo.OldY,10)
end if
if MouseInfo.Right then
drawdot (MouseInfo.X, MouseInfo.Y, 12)
drawline (MouseInfo.X, MouseInfo.Y,MouseInfo.OldX, MouseInfo.OldY,12)
end if
View.Update
end loop
|