Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drop Down Menu
#5
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.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
Drop Down Menu - by Dimster - 05-11-2022, 02:35 PM
RE: Drop Down Menu - by SMcNeill - 05-11-2022, 03:21 PM
RE: Drop Down Menu - by Dimster - 05-11-2022, 06:51 PM
RE: Drop Down Menu - by Dimster - 05-12-2022, 05:32 PM
RE: Drop Down Menu - by bplus - 05-12-2022, 06:58 PM
RE: Drop Down Menu - by Dimster - 05-12-2022, 08:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Universal Menu Concept Pete 3 396 01-05-2026, 07:31 PM
Last Post: Pete
  Is there a menu function? Mad Axeman 17 1,184 12-17-2025, 04:43 AM
Last Post: SMcNeill
  performance drop on LINUX with PSET in v4.2 Herve 12 1,017 11-20-2025, 02:00 PM
Last Post: SpriggsySpriggs
  Trying to create a simple menu CMR 8 1,256 06-18-2025, 06:59 PM
Last Post: CookieOscar
  Another way to use Hardware Images and Transparency (alpha channel) for a PopUp Menu TempodiBasic 1 532 03-30-2025, 05:10 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)