Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DAY 016: _MOUSEINPUT
#16
Ever notice that some apps trigger an event when the left mouse is pressed, but a few trigger it only after the left mouse button once pressed is released? The following demonstrates how this can be accomplished...

Code: (Select All)
REM click_event = 1 to initiate on button press.
REM click_event = 2 to initiate on button release.

VIEW PRINT 1 TO 23
click_event = 1
LOCATE 25, 1: PRINT "Event triggered on left button press. Press 2 to change."
LOCATE 1, 1
DO
    _LIMIT 30
    b$ = INKEY$
    IF LEN(b$) AND lb = 0 THEN
        IF b$ = "1" THEN click_event = 1: y = CSRLIN: x = POS(0): LOCATE 25, 1: PRINT "Event triggered on left button press. Press 2 to change.  ";: LOCATE y, x
        IF b$ = "2" THEN click_event = 2: y = CSRLIN: x = POS(0): LOCATE 25, 1: PRINT "Event triggered on left button release. Press 1 to change.";: LOCATE y, x
    END IF
    WHILE _MOUSEINPUT: WEND
    IF _MOUSEBUTTON(1) THEN
        IF lb = 0 THEN lb = -1
    ELSE
        IF lb THEN
            IF click_event = -2 THEN CALL event
            lb = 0: click_event = ABS(click_event) ' Button release.
        END IF
    END IF

    IF lb AND click_event = 1 THEN CALL event: click_event = -1 '  Event on button down.
    IF lb AND click_event = 2 THEN click_event = -2 ' Event when button down is released.
LOOP

SUB event
    SOUND 1000, .2
    PRINT "Pete!"
END SUB

Pete
Reply


Messages In This Thread
DAY 016: _MOUSEINPUT - by SMcNeill - 11-21-2022, 11:27 PM
RE: DAY 016: _MOUSEINPUT - by bplus - 11-21-2022, 11:41 PM
RE: DAY 016: _MOUSEINPUT - by SMcNeill - 11-22-2022, 12:09 AM
RE: DAY 016: _MOUSEINPUT - by PhilOfPerth - 11-22-2022, 12:16 AM
RE: DAY 016: _MOUSEINPUT - by james2464 - 11-22-2022, 12:20 AM
RE: DAY 016: _MOUSEINPUT - by SMcNeill - 11-22-2022, 12:32 AM
RE: DAY 016: _MOUSEINPUT - by mnrvovrfc - 11-21-2022, 11:54 PM
RE: DAY 016: _MOUSEINPUT - by PhilOfPerth - 11-22-2022, 12:08 AM
RE: DAY 016: _MOUSEINPUT - by james2464 - 11-22-2022, 12:38 AM
RE: DAY 016: _MOUSEINPUT - by SMcNeill - 11-22-2022, 12:49 AM
RE: DAY 016: _MOUSEINPUT - by mnrvovrfc - 11-22-2022, 12:46 AM
RE: DAY 016: _MOUSEINPUT - by Pete - 11-22-2022, 01:32 AM
RE: DAY 016: _MOUSEINPUT - by SMcNeill - 11-22-2022, 02:00 AM
RE: DAY 016: _MOUSEINPUT - by OldMoses - 12-06-2022, 01:39 AM
RE: DAY 016: _MOUSEINPUT - by Pete - 12-06-2022, 02:28 AM
RE: DAY 016: _MOUSEINPUT - by Pete - 11-22-2022, 02:59 AM
RE: DAY 016: _MOUSEINPUT - by SMcNeill - 11-22-2022, 03:47 AM
RE: DAY 016: _MOUSEINPUT - by Pete - 11-22-2022, 07:54 AM
RE: DAY 016: _MOUSEINPUT - by mnrvovrfc - 12-05-2022, 02:03 PM
RE: DAY 016: _MOUSEINPUT - by Pete - 12-05-2022, 04:02 PM
RE: DAY 016: _MOUSEINPUT - by SMcNeill - 12-05-2022, 04:55 PM
RE: DAY 016: _MOUSEINPUT - by Pete - 12-05-2022, 07:45 PM
RE: DAY 016: _MOUSEINPUT - by OldMoses - 12-06-2022, 02:26 PM
RE: DAY 016: _MOUSEINPUT - by Pete - 12-06-2022, 03:23 PM
RE: DAY 016: _MOUSEINPUT - by NasaCow - 12-10-2022, 12:28 PM
RE: DAY 016: _MOUSEINPUT - by Pete - 12-10-2022, 05:08 PM



Users browsing this thread: 1 Guest(s)