So verbose
Here a little less LOC:
Here a little less LOC:
Code: (Select All)
_Title "Quick Menu" ' b+ 2024-12-20
Screen _NewImage(800, 600, 32): _ScreenMove 250, 60
Dim menu$(1 To 4)
menu$(1) = "Help": menu$(2) = "Save": menu$(3) = "Laugh at Pete's joke": menu$(4) = "Quit"
Cls , &HFF000088: _PrintMode _KeepBackground
Do
sel = getButtonNumberChoice%(menu$())
Print "You picked: "; menu$(sel)
Loop Until sel = 4
Sub drwBtn (x, y, s$) '200 x 50
Dim fc~&, bc~&
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
fc~& = _DefaultColor: bc~& = _BackgroundColor ' save color before we chnge
Color _RGB32(0, 0, 0), &HFFBABABA
_PrintString (x + 100 - 4 * Len(s$), y + 17), s$
Color fc~&, bc~& ' restore color
End Sub
'this works pretty good for a menu of buttons to get menu number
Function getButtonNumberChoice% (choice$()) 'this sub uses drwBtn
ub = UBound(choice$): lb = LBound(choice$)
For b = lb To ub ' drawing a column of buttons at _width - 210 starting at y = 10
drwBtn _Width - 210, b * 60 + 10, choice$(b)
Next
Do
While _MouseInput: Wend
mx = _MouseX: my = _MouseY: mb = _MouseButton(1)
If mb Then
_Delay .25 ' delay before exit to give user time to release mouse button
If mx > _Width - 210 And mx <= _Width - 10 Then
For b = lb To ub
If my >= b * 60 + 10 And my <= b * 60 + 60 Then
getButtonNumberChoice% = b: Exit Function
End If
Next
Beep
Else
Beep
End If
End If
_Limit 60
Loop
End Function
b = b + ...