Skip to content

Instantly share code, notes, and snippets.

@greggirwin
Last active July 22, 2017 10:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greggirwin/c67d640f09e9ccd0dac0859ec7374ca3 to your computer and use it in GitHub Desktop.
Save greggirwin/c67d640f09e9ccd0dac0859ec7374ca3 to your computer and use it in GitHub Desktop.
VID drop-down style demo
Red [
title: "Drop-down demo"
author: "Gregg Irwin"
]
; The data facet accepts arbitrary values, but only string values will be added
; to the list and displayed. Extra, non-string values can be used to create
; associative arrays, using strings as keys. The `selected` facet is a 1-based
; integer index, indicating the position of the selected string in the list,
; not in the `data` facet.
show-action: func [face type][
print [
now/time type
"selected:" face/selected
"text:" face/text
"find*:" mold select face/data face/text
"pick*:" mold pick face/data face/selected * 2
]
]
view [
drop-down
data ["Alpha" #1 "Beta" 2x2 "Gamma" #"C"]
select 2 ; Set default list item
on-select [show-action face 'select]
on-change [show-action face 'change]
drop-down
data [#4 "Delta" 5x5 "Epsilon" %"After Epsilon" #"F" "Zeta"]
on-select [show-action face 'select]
on-change [show-action face 'change]
drop-down
data ["A" "B" "C" "D" "E" "F"]
on-select [show-action face 'select]
on-change [show-action face 'change]
]
@greggirwin
Copy link
Author

Updated to show more behavior with non-string data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment