Microsoft KB Archive/40951: Difference between revisions
(importing KB archive) |
m (Text replacement - "<" to "<") |
||
Line 50: | Line 50: | ||
The following is a code example: | The following is a code example: | ||
<pre class="codesample">PRINT "Click in right window border to quit" | <pre class="codesample">PRINT "Click in right window border to quit" | ||
WHILE x | WHILE x < 490 ' Quits if you click beyond 490 pixels to right. | ||
WHILE MOUSE(0)=0 : WEND ' Wait for mouse button to go down. | WHILE MOUSE(0)=0 : WEND ' Wait for mouse button to go down. | ||
GOSUB delay ' Delay long enough for user to triple click. | GOSUB delay ' Delay long enough for user to triple click. | ||
Line 56: | Line 56: | ||
buttonstatus=MOUSE(0) ' Read current mouse status. | buttonstatus=MOUSE(0) ' Read current mouse status. | ||
x=MOUSE(1) ' Returns X coordinate of mouse. | x=MOUSE(1) ' Returns X coordinate of mouse. | ||
IF buttonstatus | IF buttonstatus < 0 THEN GOTO waitup ' Avoids down status. | ||
PRINT "buttonstatus=",buttonstatus | PRINT "buttonstatus=",buttonstatus | ||
IF buttonstatus=1 THEN PRINT "Single clicked" | IF buttonstatus=1 THEN PRINT "Single clicked" |
Latest revision as of 09:25, 21 July 2020
Article ID: 40951
Article Last Modified on 1/8/2003
APPLIES TO
- Microsoft QuickBasic Compiler for Macintosh 1.0
This article was previously published under Q40951
SUMMARY
Mouse programming is very dependent on timing between mouse clicks. The System Control Panel is used to set the current mouse click timing rate.
This article contains a sample program that shows how to poll the MOUSE(0) function in a loop. The program detects single, double, and triple clicks in Macintosh QuickBASIC Version 1.00, BASIC Compiler Version 1.00, and BASIC Interpreter for the Macintosh Versions 2.00, 2.10, and 3.00.
The following is a code example:
PRINT "Click in right window border to quit" WHILE x < 490 ' Quits if you click beyond 490 pixels to right. WHILE MOUSE(0)=0 : WEND ' Wait for mouse button to go down. GOSUB delay ' Delay long enough for user to triple click. waitup: buttonstatus=MOUSE(0) ' Read current mouse status. x=MOUSE(1) ' Returns X coordinate of mouse. IF buttonstatus < 0 THEN GOTO waitup ' Avoids down status. PRINT "buttonstatus=",buttonstatus IF buttonstatus=1 THEN PRINT "Single clicked" IF buttonstatus=2 THEN PRINT "Double clicked" IF buttonstatus=3 THEN PRINT "Triple clicked" WEND END REM Please note: If the mouse is clicked three times at a rate that REM nearly exceeds the system time period for a triple REM click, the program may report a double and a REM triple click. delay: PRINT "Now waiting for clicking to finish . . ." ' If compiled, then use a longer loop: IF SYSTEM(4) THEN ' SYSTEM(4) returns "true" if compiled. FOR I=1 TO 7000 : NEXT ELSE ' Use shorter loop if run in interpreter: FOR I=1 TO 1100 : NEXT END IF REM The SYSTEM(4) command is not supported in the Macintosh BASIC REM Interpreter or Compiler products. When using either product, REM comment the IF...END IF loop and uncomment the loop that follows. REM FOR I=1 TO 7000 : NEXT 'Use a shorter loop if run in interpreter PRINT " . . . time is up." RETURN
Program notes:
The delay loop in this program has different timing on a Mac Plus than it does on a Macintosh II. To make the program behave the same on different Macintosh computers, replace the program's loop with another loop based on calling the ToolBox statement to invoke the TickCount ROM function. (Query on the word "tickcount" in this database for an example of a timer accurate to one-sixtieth of a second).
Additional query words: BasicCom MQuickB
Keywords: KB40951