LOL!
Well, if you are ever faced with a situation where you need to keep track of the time your cat is and is not on your mouse, you can't be stuck in a loop. That's why I made the more complicated routine, CATWATCH!
Oh, I also moved the highlighting routine from the first snippet into the mouse button NOT down condition. That way, if someone drags the held down mouse to the "X" the "X" won't be highlighted. It can now only be highlighted when hovering with the left mouse button up.
Pete
Well, if you are ever faced with a situation where you need to keep track of the time your cat is and is not on your mouse, you can't be stuck in a loop. That's why I made the more complicated routine, CATWATCH!
Code: (Select All)
DIM mse AS mm ' Let's do a TYPE instead of passing all variables or doing a DIM SHARE.
WIDTH 50, 25
_FONT 16
TYPE mm
my AS INTEGER
mx AS INTEGER
oldmy AS INTEGER
oldmx AS INTEGER
lb AS INTEGER
END TYPE
PALETTE 1, 8
COLOR 9, 1: CLS
COLOR 0, 7
PALETTE 5, 63: PALETTE 6, 63
icon_x = _WIDTH - 1 ' Row.
icon_y = 2 ' Column.
COLOR 0, 6: LOCATE icon_y, 1: PRINT SPACE$(_WIDTH);
COLOR 0, 5: LOCATE icon_y, icon_x: PRINT "X"; ' Place an exit symbol on the screen.
VIEW PRINT 4 TO _HEIGHT
z1 = TIMER
DO
_LIMIT 30
mini_mouse mse ' Poll the mini mouse routine.
IF mse.lb THEN ' Left button down.
IF catwatch THEN
SOUND 200, .2
COLOR 15, 1: LOCATE 5, 1: PRINT " Miss Whiskers has her kitty-butt on your mouse!"
catwatch = 1 - catwatch: z1 = TIMER
IF trigger = hotspot THEN activate = hotspot ' Setting activate means we mouse clicked down on it but haven't released yet.
END IF
ELSE
' Highlight the exit icon on hover, but only once so it isn't going on and off like hell. The oldmx variables insure this once and done action.
IF mse.my = icon_y AND mse.mx = icon_x AND mse_old.my <> mse.my AND mse_old.mx <> mse.mx THEN
hotspot = ((mse.my - 1) * _WIDTH + mse.mx - 1) + 1 ' Matrix the screen to combine the row and column values as a single variable.
trigger = hotspot ' Just a shorthand way so we don't keep using ((mse.my - 1) * _WIDTH + mse.mx - 1) + 1
PALETTE 5, 4: PALETTE 0, 63
ELSE ' When no longer hovering on exit icon reset the variables and lose the highlighting.
hotspot = 0: trigger = 0
PALETTE 5, 63: PALETTE 0, 0
END IF
IF catwatch = 0 THEN
COLOR 15, 1: LOCATE 5, 1: PRINT " Miss Whiskers is eyeballing your laptop... ";
catwatch = 1 - catwatch: z1 = TIMER
END IF
IF activate THEN ' When button is released we check to see if the exit icon was clicked and if the mouse pointer is still on the icon.
IF activate = hotspot THEN
SYSTEM ' Quit.
ELSE
activate = 0: trigger = 0: hotspot = 0 ' The mouse cursor got moved so the exit was avoided.
END IF
END IF
END IF
LOCATE 7, 2: PRINT "Cat Watch Timer: "; INT(ABS(z1 - TIMER))
REM LOCATE 7, 1: PRINT mse.my; mse.mx; mse_old.my; mse_old.mx; trigger; hotspot; activate; " ";
LOOP
SUB mini_mouse (mse AS mm)
mse_old.my = mse.my: mse_old.mx = mse.mx
WHILE _MOUSEINPUT: WEND
mse.mx = _MOUSEX
mse.my = _MOUSEY
mse.lb = _MOUSEINPUT(1)
IF mse.lb AND _MOUSEBUTTON(1) = 0 THEN
mse.lb = 0
ELSE
IF mse.lb = 0 AND _MOUSEBUTTON(1) THEN
mse.lb = -1
END IF
END IF
END SUB
Oh, I also moved the highlighting routine from the first snippet into the mouse button NOT down condition. That way, if someone drags the held down mouse to the "X" the "X" won't be highlighted. It can now only be highlighted when hovering with the left mouse button up.
Pete
If eggs are brain food, Biden takes his scrambled.