08-03-2022, 07:51 PM
Quote:Programming for proper mouse input could be PITA. Once I tried to fix B+ "lights on" program I think it was, changed it so it accepted mouse input but it was a real battle. The great problem is when there is an area of the program window that must accept the input, and the user holds one of the mouse buttons while dragging the cursor to outside that area. Kept fixing it and encountered another problem of retriggering left button which is very annoying in a game.
Code: (Select All)
_Title "Screen 0 Mouse Demo 2: Its a Drag"
Do
Cls
Print "Go ahead and drag your mouse!"
While _MouseInput: Wend ' poll mouse
If _MouseButton(1) Then
mdx = _MouseX: mdy = _MouseY
While _MouseButton(1)
While _MouseInput: Wend ' poll mouse
mx = _MouseX: my = _MouseY
Cls
Print "Go ahead and drag your mouse!"
If mdx < mx Then
startX = mdx: endX = mx
Else
startX = mx: endX = mdx
End If
If mdy < my Then
starty = mdy: endy = my
Else
starty = my: endy = mdy
End If
For x = startX To endX
For y = starty To endy
Locate y, x: Print "X";
Next
Next
_Display
_Limit 600
Wend
For x = startX To endX
For y = starty To endy
Locate y, x: Print "X";
Next
Next
_Display
_Limit 600
End If
Loop Until Len(InKey$)
Where is says:
Cl
Code: (Select All)
Cls
Print "Go ahead and drag your mouse!"
That's were you'd redraw the screen image if you are painting X's over an area.
b = b + ...