嘿,
我已经很多年没有这样做了,现在正尝试在 JSL 中构建一个非常小的 UI 组件,但我发现自己很挣扎。
我在列表框中有一个表列表,我想在列表框中选择该表时显示该表的描述,
这是一个最小的例子:

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(""),
),
);
);您可以看到我已经尝试了一个函数,该函数将在上面的代码中显示正确的描述,并且如果我手动运行它,该函数可以正常工作。
我的问题是我找不到列表框该功能的良好触发器。我已经浏览了脚本索引,但只能找到“关闭时”。
有没有一种简单的方法可以实现我在这里寻找的目标?
提前致谢,
丹尼尔
这是<
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 ) ) ) );您有三个选项:On Change、<< Set Function 和 << Set Script。您可以从脚本索引中找到所有这些的示例(这些示例可能不包括列表框,但它们应该以与用于演示的其他显示框类似的方式工作)。我最有可能使用 << Set Function,因为它提供了对“自身”的引用(列表框调用该函数)。