Mapping screen for mouse
#2
hello Phil, using the example of _MOUSEX in qb64 wiki, a few modifications, detect if mouse down on left side of screen (1) or right side of screen (2)

 is the beginning, you add more sectors to detect:

Code: (Select All)
DIM mousesector(10, 5) AS INTEGER

mousesector(1, 1) = 1 'xi
mousesector(1, 2) = 1 'yi
mousesector(1, 3) = 320 'xf
mousesector(1, 4) = 480 'yf
mousesector(1, 5) = 1 'option selected

mousesector(2, 1) = 321 'xi
mousesector(2, 2) = 1 'yi
mousesector(2, 3) = 639 'xf
mousesector(2, 4) = 480 'yf
mousesector(2, 5) = 2 'option selected


SCREEN 12
LINE (99, 9)-(601, 401), 7, BF
LINE (101, 11)-(599, 399), 8, BF
tm$ = " Column = ###  Row = ###  Button1 = ##  Button2 = ##  Button3 = ##"
LOCATE 29, 20: PRINT "LeftButton = draw - RightButton = Erase";
DO: K$ = INKEY$
    DO WHILE _MOUSEINPUT
        X = _MOUSEX: Y = _MOUSEY
        IF X > 100 AND X < 600 AND PX > 100 AND PX < 600 THEN
            IF Y > 10 AND Y < 400 AND PY > 10 AND PY < 400 THEN
                IF _MOUSEBUTTON(1) THEN LINE (PX, PY)-(X, Y), 15
                IF _MOUSEBUTTON(2) THEN LINE (101, 11)-(599, 399), 8, BF
            END IF
        END IF
        PX = X: PY = Y
        LOCATE 27, 10: PRINT USING tm$; X; Y; _MOUSEBUTTON(1); _MOUSEBUTTON(2); _MOUSEBUTTON(3)        
    LOOP
    '---------------------- code detecting sector --------------
    IF _MOUSEBUTTON(1) THEN
        FOR i = 1 TO 2
            IF X > mousesector(i, 1) AND Y > mousesector(i, 2) AND X < mousesector(i, 3) AND Y < mousesector(i, 4) THEN
                OptionSelected = mousesector(i, 5)
            END IF
        NEXT
    END IF

    LOCATE 28, 19: PRINT "OPTION SELECTED: "; OptionSelected
    '----------------- end code -------------

LOOP UNTIL K$ = CHR$(27)
SYSTEM
Reply


Messages In This Thread
Mapping screen for mouse - by PhilOfPerth - 08-07-2023, 01:52 AM
RE: Mapping screen for mouse - by commandvom - 08-07-2023, 02:32 AM
RE: Mapping screen for mouse - by mnrvovrfc - 08-07-2023, 03:36 AM
RE: Mapping screen for mouse - by mnrvovrfc - 08-07-2023, 03:51 AM
RE: Mapping screen for mouse - by PhilOfPerth - 08-07-2023, 04:14 AM
RE: Mapping screen for mouse - by SMcNeill - 08-07-2023, 07:25 AM
RE: Mapping screen for mouse - by PhilOfPerth - 08-08-2023, 06:53 AM
RE: Mapping screen for mouse - by TerryRitchie - 08-07-2023, 08:36 AM
RE: Mapping screen for mouse - by grymmjack - 08-07-2023, 02:32 PM
RE: Mapping screen for mouse - by TerryRitchie - 08-07-2023, 03:29 PM
RE: Mapping screen for mouse - by grymmjack - 08-08-2023, 12:12 AM
RE: Mapping screen for mouse - by TerryRitchie - 08-08-2023, 05:10 PM
RE: Mapping screen for mouse - by bplus - 08-07-2023, 02:36 PM
RE: Mapping screen for mouse - by TerryRitchie - 08-07-2023, 03:34 PM
RE: Mapping screen for mouse - by CharlieJV - 08-07-2023, 09:37 PM
RE: Mapping screen for mouse - by grymmjack - 08-08-2023, 12:17 AM
RE: Mapping screen for mouse - by CharlieJV - 08-08-2023, 01:53 AM
RE: Mapping screen for mouse - by grymmjack - 08-08-2023, 12:11 AM
RE: Mapping screen for mouse - by mnrvovrfc - 08-08-2023, 12:37 PM
RE: Mapping screen for mouse - by bplus - 08-07-2023, 05:44 PM
RE: Mapping screen for mouse - by justsomeguy - 08-07-2023, 07:55 PM
RE: Mapping screen for mouse - by CharlieJV - 08-07-2023, 09:35 PM
RE: Mapping screen for mouse - by grymmjack - 08-08-2023, 12:07 AM
RE: Mapping screen for mouse - by mdijkens - 08-08-2023, 10:24 AM
RE: Mapping screen for mouse - by bplus - 08-07-2023, 08:47 PM
RE: Mapping screen for mouse - by justsomeguy - 08-07-2023, 09:16 PM
RE: Mapping screen for mouse - by justsomeguy - 08-07-2023, 09:22 PM
RE: Mapping screen for mouse - by CharlieJV - 08-07-2023, 09:46 PM
RE: Mapping screen for mouse - by justsomeguy - 08-07-2023, 10:03 PM
RE: Mapping screen for mouse - by CharlieJV - 08-07-2023, 10:57 PM
RE: Mapping screen for mouse - by bplus - 08-07-2023, 11:37 PM
RE: Mapping screen for mouse - by TerryRitchie - 08-08-2023, 02:45 AM
RE: Mapping screen for mouse - by PhilOfPerth - 08-08-2023, 06:59 AM
RE: Mapping screen for mouse - by bplus - 08-08-2023, 12:25 PM
RE: Mapping screen for mouse - by mdijkens - 08-08-2023, 01:16 PM
RE: Mapping screen for mouse - by justsomeguy - 08-08-2023, 06:59 PM



Users browsing this thread: 3 Guest(s)