12-10-2022, 12:28 PM
So.... I read through this and I want to check my conceptual understanding here.
Best to setup a mouse reading sub to poll the current state of the mouse. A basic sub should collect our x,y position (assuming that is in pixels in our program when it is active?), and the state of the left button (assuming the right button is as simple?). I get a little fuzzy on checking the prior state of the button to the current state... Is this to check if the button is still being held down and we don't execute as a general rule in such a state? Or did I miss something? Assuming I don't highlight items, I don't need to worry about holding and dragging?
In addition, I assume if I want mouse-reading ability, I would need to place a sub call in each of the do/loops I have in my program where I want to use said mouse? And similiar to keyboard input, I would use a select case and check if at this x and y (do I need to track the start x,y and release x,y to ensure I am still in a defined box click area?) with this mouse click and release flag then do this code. Am I getting the logic right or am missing something here.
So conceptual it would look like this, if I am understanding the logic right:
Thank you Steve and Pete. I did start in the wiki but this was much more informative.
Best to setup a mouse reading sub to poll the current state of the mouse. A basic sub should collect our x,y position (assuming that is in pixels in our program when it is active?), and the state of the left button (assuming the right button is as simple?). I get a little fuzzy on checking the prior state of the button to the current state... Is this to check if the button is still being held down and we don't execute as a general rule in such a state? Or did I miss something? Assuming I don't highlight items, I don't need to worry about holding and dragging?
In addition, I assume if I want mouse-reading ability, I would need to place a sub call in each of the do/loops I have in my program where I want to use said mouse? And similiar to keyboard input, I would use a select case and check if at this x and y (do I need to track the start x,y and release x,y to ensure I am still in a defined box click area?) with this mouse click and release flag then do this code. Am I getting the logic right or am missing something here.
So conceptual it would look like this, if I am understanding the logic right:
Code: (Select All)
DO
LIMIT LIMITRATE
'INSERT MOUSE READING SUB HERE
CLS
PUTIMAGE (0, 0), Intro
SELECT CASE Pointer 'Used for keyboard selection
CASE 0: PUTIMAGE (375, 221), CheckSelect
CASE 1: PUTIMAGE (375, 292), CheckSelect
CASE 2: PUTIMAGE (375, 365), CheckSelect
CASE 3: PUTIMAGE (375, 437), CheckSelect
CASE 4: PUTIMAGE (375, 510), CheckSelect
END SELECT
DISPLAY
IF SelectFlag THEN PAUSE (TIME) 'Avoid double press delay
SelectFlag = FALSE
'Checking for key press (keyboard)
IF KEYDOWN(CVI(CHR$(0) + "H")) THEN ' up case
IF Pointer = 0 THEN Pointer = 4 ELSE Pointer = Pointer - 1
SelectFlag = TRUE
END IF
IF KEYDOWN(CVI(CHR$(0) + "P")) THEN 'down case
IF Pointer = 4 THEN Pointer = 0 ELSE Pointer = Pointer + 1
SelectFlag = TRUE
END IF
'Some kind of if/then or select case to check for mouse actions?
LOOP UNTIL KEYDOWN(13) OR KEYDOWN(32) 'Return/Spacebar to select - include a mouse flag that a choice was made???
Thank you Steve and Pete. I did start in the wiki but this was much more informative.