How I build these changes case by case, but using Filter Col Selector is fairly simple (usually I don't have to worry about the private tables, but I don't know your use case, so I did some trickery for them)
Names Default To Here(1);
create_filter = function({items}, {Default Local},
dt = New Table("",
New Column("a", Character, Values(items)),
private
);
dt_split = dt << Split(
Split By(:a),
Split(:a),
Output Table("temp"),
Sort by Column Property,
private
);
Close(dt, no save);
Eval(EvalExpr(
fcs = Filter Col Selector(dt_split, << Set Script(
Expr(dt_split); // not sure how robust this will be, used to store the private table reference
));
));
return(fcs);
);
item_list1 = {"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida",
"Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine",
"Maryland", "Massachusetts", "Michigan", "Minnesota"};
item_list2 = {"Mississippi", "Missouri", "Montana", "Nebraska",
"Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio",
"Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas",
"Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
nw = New Window("demo",
H List Box(
a = create_filter(item_list1),
b = create_filter(item_list2)
)
);
You can also use V List Box and build it using Text Edit Box (you want to store the original list somewhere)
Names Default To Here(1);
create_filter = function({items}, {Default Local},
Eval(EvalExpr(
vlb = V List Box(
Text Edit Box("", <<Set Text Changed(Function({this, value},
all_items = Expr(items);
new_list = Filter Each({name}, all_items, Contains(lowercase(name), lowercase(value)));
If(N Items(new_list) == 0 & IsMissing(value),
new_list = all_items;
);
(this << sib) << set items(new_list)
))),
List Box(items)
);
));
return(vlb);
);
item_list1 = {"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida",
"Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine",
"Maryland", "Massachusetts", "Michigan", "Minnesota"};
item_list2 = {"Mississippi", "Missouri", "Montana", "Nebraska",
"Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio",
"Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas",
"Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
nw = New Window("demo",
H List Box(
vlb1 = create_filter(item_list1),
vlb2 = create_filter(item_list2)
)
);
and there are also other methods depending on the application and use case.
-Jarmo