IF demo%
THEN PRINT "Press keys or use mouse for demo.";
MenuSetup
= MenuSetup
+ 1:
GOSUB MenuSetup
CALL keyboard_mouse
(UI
, mydemo%
) UI.MbEnvoked = -1
MenuSetup:
MenuType% = 1
DrawBox% = -1
MenuX = 0 ' Auto-Center
MenuY = 0 ' Auto-Center
Menu$(1) = "[Enter] Next Menu"
Menu$(2) = "[F1] Help"
Menu$(3) = "[F5] Save"
Menu$(4) = "[F12] Run Demo"
Menu$(5) = "[Esc] End"
Menu$(6) = ""
Menu$(7) = ""
Menu$(8) = ""
Menu$(9) = ""
Menu$(10) = ""
MenuType% = 2
DrawBox% = 0
MenuX = 0 ' Auto-Center
MenuY = 0 ' Auto-Center
Menu$(1) = "[Enter] Next Menu"
Menu$(2) = "[F1] Help"
Menu$(3) = "[F5] Save"
Menu$(4) = "[F12] Run Demo"
Menu$(5) = "[Esc] End"
Menu$(6) = ""
Menu$(7) = ""
Menu$(8) = ""
Menu$(9) = ""
Menu$(10) = ""
x = 0
Menu$ = "": x$ = "": k = 0
k
= k
+ 1: Menu$
= Menu$
+ CHR$(255) + Menu$
(i
)
DrawBox:
FindMenu:
CLS:
PRINT "You did not assign a value to the variable: MenuType":
END ''' IF UI.my
>= MenuY
AND UI.my
<= MenuY
+ noe
- 1 THEN x$ = ""
FOR i
= MenuX
TO MenuX
+ x
x$ = x$ + a$
flag = 0
x$ = ""
x$ = x$ + a$
x$ = "" ' Mouse is not on a menu item.
CLS:
PRINT "You assigned a value to MenuType that was out-of-range.":
END '''
SUB keyboard_mouse
(UI
AS UserInput
, mydemo%
)
UI.KeyCombos = 1 ' Shift % = -1 ELSE shift% = 0
UI.KeyCombos = 2 ' Ctrl % = -1 ELSE ctrl% = 0
UI.KeyCombos = 3 ' Alt % = -1
UI.KeyCombos = 4 ' Ctrl+Shift % = -1 ELSE ctrlshift% = 0
UI.KeyCombos = 0
IF LEN(UI.KeyPress
) THEN ' A key was pressed. UI.MbEnvoked = 0: UI.MbLeftx = 0
CASE 1 ' 1-byte key A-Z, etc. ' Place key selection routine here...
CASE 2 '2-byte key F1-F12, etc. ' Place key selection routine here...
ELSE ' Check for mouse input since no keyboard input was detected.
IF lclick
THEN ' Check timer for double-clicks. IF TIMER < z1
THEN z1
= z1
- 86400 ' Midnight adjustment. IF TIMER - z1
> .33 THEN lclick
= 0 ' Too much time ellapsed for a double click.
' Get mouse status.
IF UI.MbStatus
< 0 THEN ' Mouse button pressed. UI.MbStatus identity is by number. -1=left, -2=right, -3=middle. CASE -1 ' Left button was pressed. IF lb
= 0 THEN ' Left button released. SELECT CASE lclick
' Single or double click analysis. lclick = lclick + 1
CASE ELSE ' Double click. Completed upon 2nd left button release. UI.DoubleClick = -1
lclick = 0
UI.MbStatus = 1
IF UI.mx
<> UI.MbLeftx
OR UI.my
<> UI.MbLefty
THEN UI.MbStatus
= 0: lclick
= 0 UI.MbLeftx = 0: UI.MbLefty = 0
ELSE ' Left button is being held down. Check for UI.drag. IF UI.mx
<> UI.oldmx
OR UI.my
<> UI.oldmy
THEN ' Mouse cursor has moved. UI.drag. UI.drag = -1
CASE -2 ' Right button was pressed. IF rb
= 0 THEN ' Right button was relased. UI.MbStatus = 2
CASE -3 ' Middle button was pressed IF mb
= 0 THEN ' Middle button was released. UI.MbStatus = 3
IF lb
THEN ' Left button just pressed. UI.MbStatus = -1
IF UI.MbLeftx
= 0 THEN UI.MbLeftx
= UI.mx: UI.MbLefty
= UI.my
IF UI.MbLeftx
= 0 THEN UI.MbLeftx
= UI.mx: UI.MbLefty
= UI.my
UI.MbStatus = -2
IF UI.MbLeftx
= 0 THEN UI.MbLeftx
= UI.mx: UI.MbLefty
= UI.my
UI.MbStatus = -3
UI.oldmx = UI.mx: UI.oldmy = UI.my: mw = 0 ' Mouse position past and present.
mydemo:
PRINT "1-byte Key = "; UI.KeyPress
PRINT "2-byte Key = "; UI.KeyPress
PRINT "Left button released." PRINT "Right button released." PRINT "Middle button released." PRINT "Left button down." PRINT "Right button down." PRINT "Middle button down." PRINT "Wheel scroll down." PRINT "Left button double click." mydemo% = -1
check_UI.KeyCombos:
PRINT "Shift key down. ";
PRINT "Ctrl + Shift key down. ";