Posts: 210
Threads: 25
Joined: Apr 2022
Reputation:
5
Anyone have Drop Down Menu routine with both mouse and arrow key options? I had one back in QBasic days working with arrow keys but seems I lost it when I changed to a new computer. I know I should be devoting the time to do this myself but honestly, it would be crap. If you do, maybe drop it in the Utilities section?
Posts: 1,507
Threads: 160
Joined: Apr 2022
Reputation:
116
Posts: 210
Threads: 25
Joined: Apr 2022
Reputation:
5
Thanks Steve. It's quite the tutorial and a helluva lot more to learn than the old graphic animation in QBasic, but smokes you get 3D with Terry's
Posts: 210
Threads: 25
Joined: Apr 2022
Reputation:
5
This is going back to the original code used for a Drop Down Menu. When you read Terry's tutorial it's mind boggling how far the language has come.
SCREEN 12
WIDTH 80, 60
PSET (7, 7), 1
DRAW "r100 d10 l100 u10"
SLEEP
CLS
PSET (7, 7), 1
DRAW "r100 d20 l100 u20"
SLEEP 1
CLS
PSET (7, 7), 1
DRAW "r100 d30 l100 u30"
SLEEP 1
CLS
PSET (7, 7), 1
DRAW "r100 d40 l100 u40"
SLEEP 1
CLS
LOCATE 2, 2
PRINT " Menu"
'VIEW (10, 10)-(300, 180), , 1
'LOCATE 1, 11: PRINT "A big graphics viewport";
VIEW SCREEN(7, 7)-(150, 40), , 2
FOR x = 1 TO 500000: NEXT
CLS
LOCATE 2, 2
PRINT " Menu"
PRINT " P=Pres Cyc"
'LOCATE 11, 11: PRINT " A small graphics viewport";
VIEW SCREEN(7, 7)-(150, 50), , 2
SLEEP
FOR x = 1 TO 500000: NEXT
CLS
LOCATE 2, 2
PRINT " Menu"
PRINT " P=Pres Cyc"
PRINT " H=Cyc History"
VIEW SCREEN(7, 7)-(150, 60), , 2
'SLEEP
FOR x = 1 TO 500000: NEXT
CLS
LOCATE 2, 2
PRINT " Menu"
PRINT " P=Pres Cyc"
PRINT " H=Cyc History"
PRINT " Q=Cyc Quarters"
VIEW SCREEN(7, 7)-(150, 70), , 2
'SLEEP
FOR x = 1 TO 500000: NEXT
CLS
LOCATE 2, 2
PRINT " Menu"
PRINT " P=Pres Cyc"
PRINT " H=Cyc History"
PRINT " Q=Cyc Quarters"
SLEEP
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
05-12-2022, 06:58 PM
(This post was last modified: 05-12-2022, 06:59 PM by bplus.)
Here's a Quick Menu or Button set Demo: in less than <40 LOC for 2 procedures with <20 LOC demo
Code: (Select All) Option _Explicit
Dim Shared xmax, ymax
xmax = 800: ymax = 600
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 200, 60
Dim Menu$(5), selectNumber%
Menu$(0) = "1st Choice"
Menu$(1) = "2nd Choice"
Menu$(2) = "3rd Choice"
Menu$(3) = "4th Choice"
Menu$(4) = "5th Choice"
Menu$(5) = "Quit"
Do
Color &HFFFFFFFF, &HFF000000: Cls
selectNumber% = getButtonNumberChoice%(Menu$())
Print "You selected: "; Menu$(selectNumber%); " zzz..."
Sleep
If selectNumber% = 5 Then End
Loop
'this works pretty good for a menu of buttons to get menu number
Function getButtonNumberChoice% (choice$())
Dim As Long ub, b, mx, my, mb
'this sub uses drwBtn
ub = UBound(choice$)
For b = 0 To ub ' drawing a column of buttons at xmax - 210 starting at y = 10
drwBtn xmax - 210, b * 60 + 10, choice$(b)
Next
Do
While _MouseInput: Wend
mx = _MouseX: my = _MouseY: mb = _MouseButton(1)
If mb Then
If mx > xmax - 210 And mx <= xmax - 10 Then
For b = 0 To ub
If my >= b * 60 + 10 And my <= b * 60 + 60 Then
Line (xmax - 210, 0)-(xmax, ymax), , BF
getButtonNumberChoice% = b: Exit Function
End If
Next
Beep
Else
Beep
End If
_Delay .1
End If
_Limit 60
Loop
End Function
Sub drwBtn (x, y, s$) '200 x 50
Line (x, y)-Step(200, 50), _RGB32(0, 0, 0), BF
Line (x, y)-Step(197, 47), _RGB32(255, 255, 255), BF
Line (x + 1, y + 1)-Step(197, 47), &HFFBABABA, BF
Color _RGB32(0, 0, 0), &HFFBABABA
_PrintString (x + 100 - 4 * Len(s$), y + 17), s$
End Sub
Meant to be modified to needs of application.
b = b + ...
Posts: 210
Threads: 25
Joined: Apr 2022
Reputation:
5
Thanks bplus, I just need to work out the animation for the drop down effect and I'm a winner. thanks again. I wasn't sure where to start with this.
|