Post by Chris BurrowsPost by Jack DawkinsI'm using xds Win32 which has a module MsMouse in the topspeed compatibility pack. However, it wasn't part of the original topspeed as far as I'm aware and I can't find any documentation about how to use the modules other than in the definition file. Has anyone used MsMouse? Thanks for any help.
MsMouse was in v3.1 of TopSpeed Modula-2 and is documented in the Reference Manual. The source code of the module was included but I can't find any example code.
Thanks Chris. I found some code (see URL below) which explained why my first attempt wasn't working properly. When using GetPress the actions variable is set to 1 once after a click, so you need to check for this otherwise whatever you want to happen after a click will keep occurring until the next click. Here's some code which increments n and prints its value when you click within lines 0-5 of the console, and quits when the click is located > line 20.
MODULE mouse;
IMPORT MsMouse, IO, Lib;
VAR
n : INTEGER;
gm : MsMouse.MsData;
BEGIN
MsMouse.InitMouse();
n := 0;
REPEAT
Lib.Delay(100); (* look for a click every 0.1 secs *)
MsMouse.GetPress(0, gm);
IF (gm.row >= 0) & (gm.row <= 5) & (gm.actions = 1) THEN
INC(n);
IO.WrInt(n,0);
IO.WrLn;
END;
UNTIL gm.row > 20;
END mouse.
There is some other code demonstrating mouse usage at
http://parallel.vub.ac.be/education/modula2/technology/index.html
You will also find a library (a wrapper for the Windows API) called "WimDows" here.
It was written for XDS and is supposed to be easy to use. Might be worth checking out.