BIG Problem about save selection!
hi,everybody!
i new js. few day ago, wrote "saveselection dialog.jsx". can work in "dialog" windows type. can't work while change "dialog" "palette", because want palette stay screen can use when need.
could me!
forgive me poor english, in advance help
below code:
// javascript document //(function () { var doc=app.activedocument,u,array=new array();; var w=new window("palette"),//dialog work listpnl=w.add("panel"); //listpnl.size= entry = listpnl.add ("edittext", u," type first letter"); //请输入首字进行查找 entry.graphics.font = scriptui.newfont ("arial", "", 16); entry.size=[200,30]; entry.active = true; g_slist=listpnl.add('group'); g_slist.orientation='row'; slist=g_slist.add('listbox');//,u,u,{multiselect: true} slist.alignment='left'; slist.size=[140,100]; slist.scrolling=true; orderg=g_slist.add('group'); orderg.orientation='column'; orderpnl=orderg.add('panel'); orderpnl.margins=2; orderpnl.size=[50,100]; orderpnl.alignchildren=['fill','center']; var select=orderpnl.add("button", undefined, "sel"); select.size=[40,20]; var =orderpnl.add ("button", undefined, "up");//up up.size=[40,20]; var down = orderpnl.add ("button", undefined, "down"); down.size=[40,20]; addsel=listpnl.add('button{text:"+ add 增加选择到清单"}'); addsel.size=[200,20]; deletesel=listpnl.add('button{text:"- delete 从清单中删除"}'); deletesel.size=[200,20]; updateitems (); function updateitems() { if (doc.pageitems.length>0) { (var i=0;i<doc.pageitems.length;i++) { if (doc.pageitems[i].note !='') { if (!(slist.find(doc.pageitems[i].note))) list=slist.add('item',doc.pageitems[i].note); } } } } addsel.onclick=function() { var p = prompt("save selection","name selection");//存储所选对象请输入名称 if (doc.selection.length>0 && p!=null){ var list=slist.add('item',p); (var i=0;i<doc.selection.length ;i++ ){ doc.selection[i].note=p } app.redraw() } //删除空项 delete null items (var j=0;j<slist.items.length;j++){ var replice=true; var temp=slist.items[j].text; (var k=0;k<doc.pageitems.length ;k++ ){ if (temp==doc.pageitems[k].note) replice=false; } if (replice) slist.remove(temp); } updateitems () } var temp; slist.ondoubleclick=function(){ doc.selection=null; var temp=slist.selection.text; (var i=0;i<doc.pageitems.length;i++) { if (doc.pageitems[i].note ==temp) { doc.pageitems[i].selected=true; } } app.redraw() } deletesel.onclick=function(){ if (slist.selection.length!=0) { var temp=slist.selection.text; slist.remove(temp); (var i=0;i<doc.pageitems.length;i++) { if (doc.pageitems[i].note ==temp) { doc.pageitems[i].note=''; } } } app.redraw(); updateitems (); } select.onclick=function(){ doc.selection=null; var temp=slist.selection.text; (var i=0;i<doc.pageitems.length;i++) { if (doc.pageitems[i].note ==temp) { doc.pageitems[i].selected=true; } } app.redraw() } up.onclick = function (){ var n = slist.selection.index; if (n > 0){ swap (slist.items [n-1], slist.items [n]); slist.selection = n-1; } } down.onclick = function (){ var n = slist.selection.index; if (n < slist.items.length-1){ swap (slist.items [n], slist.items [n+1]); slist.selection = n+1; } } function swap (x, y){ var temp = x.text; x.text = y.text; y.text = temp; } var array=new array(); (var n=0;n<slist.items.length;n++) { array.push(slist.items[n].text) } entry.onchanging = function (){ var tmp = this.text; tmp=tmp.tostring(); slist.removeall (); //if (tmp!='') { (var m = 0; array[m]; m++) { if (array[m].indexof (tmp) == 0) list=slist.add ('item', array[m]); if (slist.items.length > 0) slist.selection = 0; } } w.onclick=w.onmove=function () { entry.text=''; entry.active=true; } /* entry.onchange = function () { var array1=new array(); (var n=0;n<slist.items.length;n++) { array1.push(slist.items[n].text) } (var m1 = 0; array1[m1]; m1++) { list=slist.add ('item', array1[m1]); } }*/ /* function shiftlist (){ if (this.selection != null) { var idx = this.selection.pop().index; if (idx < this.items.length) this.revealitem (idx); } } */ w.show() //} //)()
hi zjbook, know i, right?
why not have @ "变量巫术师" script in cpc?
in short, "palette" panel, whenever code function dealing illustrator dom, should use bridgetalk. scriptui callback function without illustrator dom commands not need bridgetalk.
More discussions in Illustrator Scripting
adobe
Comments
Post a Comment