Skip to content
Matthias Görges edited this page Aug 6, 2020 · 8 revisions

glgui-dropdownbox create a dropdown box widget for choosing from a list of items. If there is not enough space below the box for the list to show it opens above the selected item. If there is still not enough space a scrollbar will be used within the list that appears.

Parameter Description
g Graphical User Interface (GUI) for this widget
x Lower left corner along the x-axis in pixels
y Lower left corner along the y-axis in pixels
w Width of the element in pixels
h Height of the element in pixels
lst List of procedures for drawing the items to choose from (Note: use runtime rendering functions like glgui:draw-box not widgets like glgui-box here)
arrowcolor Color of the arrow icon
bgcolor Widget background color
bordercolor Drop down list border color, also goes between items. If procedures for drawing list items have alpha and the bgcolor has alpha (or is false) than the border color will show through

Additional Attributes

Attribute Default Value Description
cboncancel #f If true, when a dropdown box is tapped again to cancel, the callback is called.
maxitems 5 Max number of items to make visible at once
current -1 Current list item selected, -1 selects no item
bidir False If true, expands dropdown list both up and down if necessary
miny 0 The minimum y value the dropdown list is allowed to extend down to, this and maxy are useful if you want the dropdown box to stay within a certain part of the app.
maxy (glgui-height-get) The maximum y value the dropdown list is allowed to extend up to.
scrollcolor DimGray The color of the scrollbar.
scrollw 5. The width of the scrollbar.
scrollrounded #f If set to true, the scrollbar is drawn as a rounded box.

Example

Example 1: Make a dropdownbox at x=140,y=200, width 150, height 40 which has three entries, which are the strings "Ear" "Hand" and "Foot"

(define field_gradient (list (color:shuffle #xe8e9eaff) (color:shuffle #xe8e9eaff) (color:shuffle #xfefefeff) (color:shuffle #xfefefeff)))
(glgui-dropdownbox gui 140 200 150 40
   (map (lambda (str)
     (lambda (lg lw x y w h s) (if s (glgui:draw-box x y w h Grey))
       (glgui:draw-text-left (+ x 5) y (- w 10) h str ascii_18.fnt Black)))
     (list "Ear" "Hand" "Foot"))
   Black field_gradient Black)
Clone this wiki locally