-
1. Re: DropDownList value selected by default?
Philip Cord Nov 20, 2014 11:33 AM (in response to Gespinha)You just have to set the selection, example.
var w, layout; layout = "dialog { \ dropdown: DropDownList { \ size: [100,20] \ properties: { \ items: ['one','two','three'] \ } \ } \ }"; w = new Window(layout); w.dropdown.selection=0; w.show(); -
2. Re: DropDownList value selected by default?
JJMack Nov 20, 2014 11:40 AM (in response to Gespinha)You need to default one. I your case 0, 1 or 2. I don't know Photoshop ScriptUI only steal other UI example and modify for my application. Here how a made font select-able note I set dd1 selection to 1 dd1 could also be change by remembering the previous run and changing dd1 prior to displaying the dialog.
dlg.msgPnl.grp6a =dlg.msgPnl.add('group');
dlg.msgPnl.grp6a.orientation='row';
dlg.msgPnl.grp6a.alignment='fill';
dlg.msgPnl.grp6a.st1 = dlg.msgPnl.grp6a.add('statictext',undefined,'Font');
fontlist = new Array();
for (var i=0,len=app.fonts.length;i
fontlist[i] = app.fonts[i].name;
}
dlg.msgPnl.grp6a.dd1 = dlg.msgPnl.grp6a.add('dropdownlist',undefined,fontlist);
dlg.msgPnl.grp6a.dd1.selection=1;
-
3. Re: DropDownList value selected by default?
Gespinha Nov 20, 2014 1:26 PM (in response to Philip Cord)Thanks, that worked
Btw, how do I return the value that is selected?
For example, I change the dropdown to 'three' and I want it to return to me the number of the selected option.
-
4. Re: Re: DropDownList value selected by default?
Philip Cord Nov 20, 2014 1:41 PM (in response to Gespinha)There are various ways here is one way to show the value when it is changed.
var w, layout; layout = "dialog { \ dropdown: DropDownList { \ size: [100,20] \ properties: { \ items: ['one','two','three'] \ } \ } \ }"; w = new Window(layout); w.dropdown.selection=0; w.dropdown.onChange= function(){ alert(w.dropdown.selection.text); } w.show(); -
5. Re: DropDownList value selected by default?
csuebele Nov 20, 2014 4:15 PM (in response to Gespinha)The drop down list will show either the text or a number. with processing the result from a dropdownlist, you want to make sure you specify what you want or you will run into issues. To get the number of the selection you would werite:
alert(parseInt(w.dropdown.selection))
-
6. Re: DropDownList value selected by default?
Gespinha Nov 20, 2014 5:02 PM (in response to Philip Cord)Thanks guys it worked



