Oh maybe we can play around with this starter code:
Modify so:
1. the buttons are stacked one above the other to fit more
2. add a parameter xAcross to designate the column to run the buttons down from
3. save the screen section before menu is displayed, display menu then replace the screen section with saved image
Code: (Select All)
_Title "Button Menu demo" ' b+ 2023-06-24
Dim menu$(1 To 10)
Screen _NewImage(800, 720, 32)
_ScreenMove 250, 0
For i = 1 To 9
menu$(i) = "This menu item #" + _Trim$(Str$(i))
Next
menu$(10) = "Quit"
Do
selectedN = getButtonNumberChoice%(menu$())
Print "You selected "; menu$(selectedN)
Loop Until selectedN = 10
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
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
Line (_Width - 210, 0)-(_Width, _Height), bColor, BF
' delay before exit to give user time to release mouse button
getButtonNumberChoice% = b: _Delay .25: Exit Function
End If
Next
Beep
Else
Beep
End If
End If
_Limit 60
Loop
End Function
Modify so:
1. the buttons are stacked one above the other to fit more
2. add a parameter xAcross to designate the column to run the buttons down from
3. save the screen section before menu is displayed, display menu then replace the screen section with saved image
b = b + ...