This will help in the case where a person wants to have ON MOUSE in a procedure or function. Very handy.
This is the current working example that also extracts the location of the mouse coordinates to xpos% and ypos% and passes the mouse button number to mb%
Code: Select all
MODE 8 PRINT"Start of program" REM: Set a mouse interrupt with ON MOUSE REM ON MOUSE: PRINT" ON MOUSE interrupt. Ending program with END. Bye":END:RETURN MOVE 100,100:PRINT "left click on the box and hold for 2 seconds" RECTANGLE 200,200,50,50 REPEAT REM ON MOUSE PROCmouse(@wparam%,@lparam%):RETURN :REM required PROCmoutest WAIT 5 UNTIL FALSE END REM thanks to Patrick for finding the usage solution for ON MOUSE LOCAL DEFPROCmoutest REM Getting a response from a mouse interupt REM: Set a local mouse interrupt with ON MOUSE LOCAL ON MOUSE LOCAL: E%=TRUE: RETURN:REM ON MOUSE LOCAL interrupt. Setting E% in order to exit loop": LOCAL E%,xpos%,ypos%,y%,mb% REM "Now entering a REPEAT loop testing variable E%" REPEAT WAIT 1 UNTIL E% :REM LOCAL E% makes E%=0: if E% becomes -1 then it is TRUE (which explains E%=TRUE....hmmmm) xpos% = (@lparam% AND &FFFF) *2 - @vdu.o.x% ypos% = (@vdu%!212-1-(@lparam% >>> 16))*2 - @vdu.o.y% mb%=(@wparam%) REM now we check the area (200,200,250,250) for mouse presence and left button) IF xpos%> 200 AND ypos%>200 AND xpos%< 250 AND ypos%<250 AND mb%=1 THEN REM if a unique mouse button is held it only will make 1 line LINE 250,250,250+RND(500),250+RND(500) ENDIF REM MOUSE STUFF ENDS HERE ENDPROC REM VERY NICE REFERENCE !!!!