Hey,
i am trying to build a very small UI component in JSL after not doing this for quite a number of years and i find my self struggling.
I have a list of tables in a listbox, and i want to display a description of the table when it is selected in the listbox,
Here is a minimal example:

tables = {"Table1", "Table2"};
descriptions = {"This is the first table", "This is the second"};
showDescription = Function({},{sel, selIdx, desc},
sel = item_disp_box << Get Selected;
If(Nitems(sel) > 0,
selIdx = loc(tables,sel[1])[1];
desc = descriptions[selIdx];
tb << Set Text(desc);
);
);
nw = new window("Browse Tables",
spacer box(size(0, 5)),
hlistbox(
panelbox("Tables:",
spacer box(size(0, 5)),
item_disp_box = listbox(tables, width(200), nlines(5), max selected(1)),
//item_disp_box << On Something??(showDescription),
),
panelbox("Description of selected table:",
tb = Text Box(""),
),
);
);You can see that i've experimented with a function that will display the correct description in the code above and that works fine if i run it manually.
My problem is that i can't find a good trigger for that function for the listbox. I've been trough the scripting index and i can only find "on close".
Is there an easy way to achieve what I am looking for here?
Thanks in advance,
Daniel
Here's the <
Names Default To Here( 1 );
New Window( "Example",
lb = List Box( {"First Item", "Second Item", "Third Item", "Fourth Item"}, width( 200 ), max selected( 2 ), nlines( 5 ) ),
Text Box( "" )
);
lb << Set Function( Function( {thisBox}, (thisBox << sib) << Set Text( Char( thisBox << get selected ) ) ) );You have three options: On Change, << Set Function and << Set Script. You can find examples for all of these from scripting index (the examples might not include List Box, but they should work for it in similar manner as the other display boxes used to demonstrate). I would most likely use << Set Function as it provides reference to "itself" (listbox calling the function).
Thank you both! The Set Function worked like a charm 