<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Listbox on selection event? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723227#M90536</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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,&lt;BR /&gt;Here is a minimal example:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DSA_0-1707483306390.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/61015i44AC78BAF46C7311/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DSA_0-1707483306390.png" alt="DSA_0-1707483306390.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tables = {"Table1", "Table2"};
descriptions = {"This is the first table", "This is the second"};

showDescription = Function({},{sel, selIdx, desc},
    sel = item_disp_box &amp;lt;&amp;lt; Get Selected;
    If(Nitems(sel) &amp;gt; 0,
        selIdx = loc(tables,sel[1])[1];
        desc = descriptions[selIdx];
        tb &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; On Something??(showDescription),
		),
		panelbox("Description of selected table:",
			tb = Text Box(""),
		),
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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".&lt;BR /&gt;&lt;BR /&gt;Is there an easy way to achieve what I am looking for here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Feb 2024 13:02:09 GMT</pubDate>
    <dc:creator>DSA</dc:creator>
    <dc:date>2024-02-09T13:02:09Z</dc:date>
    <item>
      <title>Listbox on selection event?</title>
      <link>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723227#M90536</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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,&lt;BR /&gt;Here is a minimal example:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DSA_0-1707483306390.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/61015i44AC78BAF46C7311/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DSA_0-1707483306390.png" alt="DSA_0-1707483306390.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tables = {"Table1", "Table2"};
descriptions = {"This is the first table", "This is the second"};

showDescription = Function({},{sel, selIdx, desc},
    sel = item_disp_box &amp;lt;&amp;lt; Get Selected;
    If(Nitems(sel) &amp;gt; 0,
        selIdx = loc(tables,sel[1])[1];
        desc = descriptions[selIdx];
        tb &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; On Something??(showDescription),
		),
		panelbox("Description of selected table:",
			tb = Text Box(""),
		),
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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".&lt;BR /&gt;&lt;BR /&gt;Is there an easy way to achieve what I am looking for here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 13:02:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723227#M90536</guid>
      <dc:creator>DSA</dc:creator>
      <dc:date>2024-02-09T13:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Listbox on selection event?</title>
      <link>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723238#M90538</link>
      <description>&lt;P&gt;Here's the &amp;lt;&amp;lt;Set Function (list box) example from the Scripting Index.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; Set Function( Function( {thisBox}, (thisBox &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; Set Text( Char( thisBox &amp;lt;&amp;lt; get selected ) ) ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Feb 2024 13:13:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723238#M90538</guid>
      <dc:creator>mmarchandTSI</dc:creator>
      <dc:date>2024-02-09T13:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Listbox on selection event?</title>
      <link>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723255#M90539</link>
      <description>&lt;P&gt;You have three options: On Change, &amp;lt;&amp;lt; Set Function and &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; Set Function as it provides reference to "itself" (listbox calling the function).&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 13:39:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723255#M90539</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-02-09T13:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Listbox on selection event?</title>
      <link>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723266#M90542</link>
      <description>&lt;P&gt;Thank you both! The Set Function worked like a charm :D&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 14:29:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Listbox-on-selection-event/m-p/723266#M90542</guid>
      <dc:creator>DSA</dc:creator>
      <dc:date>2024-02-09T14:29:39Z</dc:date>
    </item>
  </channel>
</rss>

