Hello! o)
Please see below code, it opens a dialog with dropdown box. The first item with index = 0 shall be preselected, but it won't.
Preselection works fine if preselection index is > 0 though. Just ncomment the //var defIndex = x lines to see the effect.
[code]@script jscript
var defIndex = 0; //preselection does not work for index 0
//var defIndex = 1; //preselection works
//var defIndex = 2; //preselection works
///////////////////////////////////////////////////////////////////////////
function OnClick(data){
var choices = DOpus.Create.Vector();
choices.push_back("0 Off");
choices.push_back("1 Xception");
choices.push_back("2 Error");
var dlg = data.func.dlg;
var result = OpenSelectBox("XLog", "Choose..", dlg, choices, defIndex);
DOpus.Output("Selected index: " + dlg.selection);
}
///////////////////////////////////////////////////////////////////////////
function OpenSelectBox(title, msg, dlg, choices, defaultIndex){
DOpus.Output("Default index: " + defaultIndex);
dlg.title = title;
dlg.message = msg;
dlg.buttons = "Ok|Cancel";
dlg.choices = choices;
dlg.selection = defaultIndex || undefined;
dlg.Show();
return dlg.result;
}
[/code]
Thank you for your attention! o)