嘿,
我已經很多年沒有這樣做了,現在正嘗試在 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,因為它提供了對“自身”的引用(列錶框呼叫該函數)。