My previous post did not work after copying and pasting into the console so i deleted it. This version does.
After selecting an item from a text-list i want to delete it from the list.
thedata: ["a" "b" "c"] selecteditems: copy  view [ te: text-list data thedata [ t: thedata/(te/selected) if not(none? t) [ append selecteditems t thedata/(te/selected): copy "" ] l: 0 foreach item thedata [ if item <> "" [ l: l + 1 ] ] if 0 = l [unview] ] ] print selecteditems ; this order is not important
This code works but there must be a nicer better way to do this.
Note: The selected items can be chosen random.
if not(none? t) [is equivalent to
if t [in this case.
thedata/(te/selected)is a bit harder to read than
pick thedata te/selectedor
at thedata te/selected.
-) when putting multiple words together as a variable name. Invest into better names, make your code read well enough in English, it will be easier to understand/maintain.
Oas variable names, as they can often be confused with
whatfrom the console and the Rebol/Core manual).
list: ["a" "b" "c"] probe collect [ view [ text-list data list on-down [ keep take at face/data face/selected if empty? face/data [unview] ] ] ]
list: ["a" "b" "c"] print collect [ view [ text-list data list on-down [ ; I need the selected item to ; store it into another text-list keep take at face/data face/selected if empty? face/data [unview] ] ] ]
face/selected. Though, the mouse events seem to not fill
event/picked, so that we need to change the event type and add some extra code to ensure that the text-list's selection does not interfere:
list: ["a" "b" "c"] probe collect [ view [ text-list data list on-change [face/selected: none] on-select [ keep take at face/data probe event/picked if empty? face/data [unview] ] ] ]
@GiuseppeChillemi @pekr some improvements:
Next is keyboard navigation and editing (probably using
fieldstyle, I will see).