combobox.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <krpano>
  2. <!--
  3. combobox.xml
  4. krpano 1.21
  5. https://krpano.com/plugins/combobox/
  6. Combobox Plugin
  7. - This plugin converts <combobox> elements in the current xml
  8. into <layer> container, scrollarea and textfield elements.
  9. - Additionally it's also possible to add and remove combobox
  10. elements also dynamically.
  11. - The full xml implementation allows many ways of customizing
  12. for own needs - custom designs/styles, custom functionality.
  13. Syntax for Static XML Code:
  14. <combobox name="..." design="..." ...any layer settings...>
  15. <item name="..." caption="..." onclick="..." />
  16. <item name="..." caption="..." onclick="..." />
  17. </combobox>
  18. Syntax for Dynamic XML Code:
  19. - Global Actions:
  20. addComboboxLayer(cbname, design*)
  21. removeComboboxLayer(cbname);
  22. - Combobox Layer Actions:
  23. layer[cbname].addItem(caption, onclick)
  24. layer[cbname].addNamedItem(name, caption, onclick)
  25. layer[cbname].addIdItem(name, caption, onclick); same as addNamedItem (for combobox.js compatibility)
  26. layer[cbname].selectItem(caption)
  27. layer[cbname].selectItemByName(name_or_index)
  28. layer[cbname].selectIdItem(name_or_index) same as selectItemByName (for combobox.js compatibility)
  29. layer[cbname].removeAll()
  30. layer[cbname].openList()
  31. layer[cbname].closeList()
  32. - Events/Callbacks:
  33. layer[cbname].onChange
  34. - Combobox Layer Attributes:
  35. layer[cbname].item - krpano Array of the items
  36. layer[cbname].selecteditemindex - current selected item index
  37. -->
  38. <!-- core internal layer styles -->
  39. <style name="combobox_container_style" type="container" maskchildren="true" bgcapture="true" visible="false" onclick="combobox_onclick_event();" alpha="1.0" />
  40. <style name="combobox_marker_style" type="text" align="righttop" edge="center" html="▼" havemarkersize="false" onautosized="set(havemarkersize,true);" alpha="1.0" />
  41. <style name="combobox_item_style" type="text" wordwrap="false" vcenter="true" align="lefttop" onover="if(!combbox_item_pressed,onoveritem());asyncloop(hovering,,if(!combbox_item_pressed,onoutitem()));" ondown="onoveritem(); set(combbox_item_pressed,true);" onup="onoutitem(); set(combbox_item_pressed,false);" onoveritem="set(bg,true);" onoutitem="set(bg,false);" alpha="1.0" />
  42. <!-- several pre-defined designs -->
  43. <combobox_design name="default" margin="2" open_close_speed="0.25">
  44. <!-- default design - white box with black text and blue selection -->
  45. <style name="combobox_container_style" bgalpha="1.0" bgcolor="0xFFFFFF" bgborder="1 0xFFFFFF 0.5" bgroundedge="1" bgshadow="0 1 3 0x000000 1.0" />
  46. <style name="combobox_marker_style" css="color:#FFFFFF;" bg="false" txtshadow="0 0 2 0x000000 1" />
  47. <style name="combobox_item_style" css="color:#222222;" padding="4 4" bg="false" bgcolor="0xC7E4FC" bgalpha="1.0" bgroundedge="1" txtshadow="0 0 1 0xFFFFFF 1.0" />
  48. </combobox_design>
  49. <combobox_design name="vtour" margin="4" open_close_speed="0.25">
  50. <!-- default vtourskin.xml design -->
  51. <style name="combobox_container_style" bgalpha="0.8" bgcolor="0x2D3E50" bgborder="0" bgroundedge="1" bgshadow="0 4 10 0x000000 0.3" />
  52. <style name="combobox_marker_style" css="color:#FFFFFF;" bg="false" txtshadow="0 0 2 0x000000 1" />
  53. <style name="combobox_item_style" css="color:#FFFFFF;" padding="4 4" bg="false" bgcolor="0xFFFFFF" bgalpha="0.5" bgroundedge="0" txtshadow="0 0 2 0x000000 1" />
  54. </combobox_design>
  55. <!-- internal events -->
  56. <events name="combobox_xml_plugin_events" keep="true"
  57. onresize="combobox_closelist();"
  58. />
  59. <!-- krpano version check -->
  60. <action name="combobox_versioncheck" autorun="preinit">
  61. if(build LT '2022-01-01',
  62. error('combobox.xml - too old krpano version!');
  63. set(events[combobox_xml_plugin_events].name, null);
  64. set(action[addComboboxLayer].content, '');
  65. set(action[removeComboboxLayer].content, '');
  66. ,
  67. combobox_xml_init();
  68. );
  69. </action>
  70. <action name="combobox_xml_init">
  71. <!-- set auto call again on next xml load -->
  72. set(action[combobox_xml_init].autorun, onload);
  73. combobox_parse_xml_elements();
  74. </action>
  75. <!-- convert all <combobox> elements to layers -->
  76. <action name="combobox_parse_xml_elements" scope="localonly">
  77. if(global.combobox,
  78. copy(combobox_src, global.combobox);
  79. delete(global.combobox);
  80. def(i, integer, 0);
  81. def(cnt, integer, get(combobox_src.count));
  82. if(cnt GT 0, loop(i LT cnt,
  83. copy(cb, combobox_src[get(i)]);
  84. if(cb AND cb.name AND cb.parsed != true,
  85. set(cb.parsed, true);
  86. addComboboxLayer(get(cb.name), get(cb.design));
  87. copy(ly, global.layer[get(cb.name)]);
  88. copyattributes(get(ly), get(cb));
  89. set(ly.keep, true);
  90. def(item_cnt, integer, get(cb.item.count));
  91. if(item_cnt GT 0,
  92. def(item_i, integer, 0);
  93. loop(item_i LT item_cnt,
  94. combobox_additem(get(ly.name), get(cb.item[get(item_i)].name), get(cb.item[get(item_i)].caption), get(cb.item[get(item_i)].onclick), get(cb.item[get(item_i)].oninit));
  95. inc(item_i);
  96. );
  97. );
  98. );
  99. inc(i);
  100. ));
  101. );
  102. </action>
  103. <!-- dynamically add a combobox layer -->
  104. <action name="addComboboxLayer" scope="localonly" args="cbname, design">
  105. <!-- create the layer -->
  106. addlayer(get(cbname));
  107. copy(cb, global.layer[get(cbname)]);
  108. set(cb.keep, true);
  109. set(cb.maxopenheight, 1000);
  110. <!-- copy the design settings (or set defaults) -->
  111. if(!global.combobox_design[get(design)].name, set(design,'default'));
  112. copy(cb.cbdesign, global.combobox_design[get(design)]);
  113. calc(cb.margin, cb.cbdesign.margin !== null ? cb.cbdesign.margin : 2);
  114. calc(cb.open_close_speed, cb.cbdesign.open_close_speed !== null ? cb.cbdesign.open_close_speed : 0.25);
  115. <!-- load the styles and copy the design style settings -->
  116. cb.loadstyle(combobox_container_style);
  117. copyattributes(get(cb), get(cb.cbdesign.style[combobox_container_style]));
  118. <!-- add/build/map actions -->
  119. calc(cb.addItem, 'combobox_additem(' + cbname + ', null, "%%1", "%%2");');
  120. calc(cb.addNamedItem, 'combobox_additem(' + cbname + ', "%%1", "%%2", "%%3");');
  121. calc(cb.addIdItem, 'combobox_additem(' + cbname + ', "%%1", "%%2", "%%3");');
  122. calc(cb.selectItem, 'combobox_finditem(' + cbname + ', "%%1", __cb_fi); if(__cb_fi GE 0, combobox_selectitem(' + cbname + ', get(__cb_fi))); delete(__cb_fi);');
  123. calc(cb.selectItemByName, 'combobox_selectitem(' + cbname + ', "%%1");');
  124. calc(cb.selectIdItem, 'combobox_selectitem(' + cbname + ', "%%1");');
  125. calc(cb.removeAll, 'combobox_removeitems(' + cbname + ');');
  126. calc(cb.openList, 'combobox_openlist(' + cbname + ');');
  127. calc(cb.closeList, 'combobox_closelist(' + cbname + ');');
  128. <!-- create sub-layers -->
  129. calc(saname, 'combobox_' + cbname + '_scrollarea');
  130. addlayer(get(saname));
  131. copy(sa, global.layer[get(saname)]);
  132. copy(sa.parent, cbname);
  133. copy(sa.keep, true);
  134. copy(sa.align, lefttop);
  135. set(sa.type, 'scrollarea');
  136. set(sa.direction, v);
  137. set(sa.enabled, false);
  138. set(sa.width, 100%);
  139. set(sa.height, 100%);
  140. copy(cb.scrollarea, sa);
  141. calc(mkname, 'combobox_' + cbname + '_marker');
  142. addlayer(get(mkname));
  143. copy(mk, global.layer[get(mkname)]);
  144. copy(mk.parent, saname);
  145. copy(mk.keep, true);
  146. mk.loadstyle(combobox_marker_style);
  147. copyattributes(get(mk), get(cb.cbdesign.style[combobox_marker_style]));
  148. copy(cb.marker, mk);
  149. <!-- item data array -->
  150. cb.createarray('item');
  151. <!-- item autosizing information -->
  152. set(cb.autosize_i, 0);
  153. set(cb.autosize_cnt, 0);
  154. set(cb.autosize_max_w, 0);
  155. set(cb.autosize_max_h, 0);
  156. set(cb.lastselecteditemindex, 0);
  157. set(cb.selecteditemindex, 0);
  158. </action>
  159. <!-- dynamically remove a combobox element -->
  160. <action name="removeComboboxLayer" scope="localonly" args="cbname">
  161. if(global.layer[get(cbname)],
  162. copy(cb, global.layer[get(cbname)]);
  163. if(cb === global.openedcombobox, delete(global.openedcombobox));
  164. if(cb,
  165. removelayer(get(cbname), true);
  166. );
  167. );
  168. </action>
  169. <!-- default onclick event for combobox elements: open the list -->
  170. <action name="combobox_onclick_event">
  171. combobox_openlist(get(name));
  172. </action>
  173. <!-- dynamically add items -->
  174. <action name="combobox_additem" scope="localonly" args="cbname, itemname, itemcaption, itemonclick, itemoninit">
  175. copy(cb, global.layer[get(cbname)]);
  176. <!-- when no item name is set, generate an automatic one -->
  177. if(itemname === null, calc(itemname, 'autoname_' + cb.item.count); );
  178. <!-- save the item caption and onclick event -->
  179. copy(cb.item[get(itemname)].caption, itemcaption);
  180. copy(cb.item[get(itemname)].onclick, itemonclick);
  181. inc(cb.autosize_cnt);
  182. <!-- create the item layer/textfield -->
  183. calc(itemlayername, 'comboboxitem_' + cbname + '_' + itemname);
  184. addlayer(get(itemlayername));
  185. copy(li, global.layer[get(itemlayername)]);
  186. li.loadstyle(combobox_item_style);
  187. copyattributes(get(li), get(cb.cbdesign.style[combobox_item_style]));
  188. copy(li.parent, cb.scrollarea.name);
  189. copy(li.keep, true);
  190. copy(li.cblayername, cb.name);
  191. copy(li.itemname, itemname);
  192. copy(li.html, itemcaption);
  193. set(li.onautosized, delayedcall(0,combobox_item_autosize_update()) );
  194. set(li.onclick, combobox_item_onclick() );
  195. if (isset(itemoninit), callwith(li, itemoninit));
  196. copy(cb.item[get(itemname)].itemlayername, itemlayername);
  197. copy(cb.item[get(itemname)].itemlayer, li);
  198. </action>
  199. <!-- onautosized callback from the item textfield -->
  200. <action name="combobox_item_autosize_update" scope="localonly">
  201. copy(cb, global.layer[get(caller.cblayername)]);
  202. inc(cb.autosize_i);
  203. Math.max(cb.autosize_max_w, caller.width);
  204. Math.max(cb.autosize_max_h, caller.height);
  205. delayedcall(calc(cb.name + '_combobox_align_items'), 0.01, calc('combobox_align_items('+cb.name+')') );
  206. </action>
  207. <!-- align the image and set the combobox size -->
  208. <action name="combobox_align_items" scope="localonly" args="cbname">
  209. copy(cb, global.layer[get(cbname)]);
  210. if(cb.marker.havemarkersize == false OR cb.scrollarea.loaded == false,
  211. <!-- wait until everything is ready -->
  212. delayedcall(calc(cb.name + '_waitformarkersize'), 0.01, combobox_align_items(get(cbname)) );
  213. ,
  214. <!-- set the item positions and the combobox size -->
  215. if(global.openedcombobox === cb, combobox_closelist() );
  216. copy(sa, cb.scrollarea);
  217. calc(itemwidth, cb.margin GT 0 ? -2 * cb.margin : '100%');
  218. copy(mk_w, cb.marker.width);
  219. copy(item_cnt, cb.autosize_cnt);
  220. for(def(item_i, integer, 0), item_i LT item_cnt, inc(item_i),
  221. copy(li, global.layer[get(cb.item[get(item_i)].itemlayername)]);
  222. set(li.x, get(cb.margin));
  223. copy(li.width, itemwidth);
  224. copy(li.height, cb.autosize_max_h);
  225. calc(li.y, cb.margin + item_i * (cb.autosize_max_h + cb.margin));
  226. );
  227. if(cb.width == null OR cb.width == cb.lastautosizedwidth,
  228. <!-- no combobox width (or an autosized width) set - set the largest item width -->
  229. calc(cb.width, cb.margin + cb.autosize_max_w + 2 + mk_w + cb.margin);
  230. copy(cb.lastautosizedwidth, cb.width);
  231. );
  232. calc(cb.height, 2*cb.margin + cb.autosize_max_h);
  233. calc(sa.height, cb.margin + item_cnt*(cb.margin+cb.autosize_max_h));
  234. calc(sa.y, -(cb.selecteditemindex * (cb.autosize_max_h + cb.margin)));
  235. calc(cb.marker.x, cb.margin + mk_w/2);
  236. tween(global.layer[get(cb.name)].marker.y, calc(cb.margin + cb.selecteditemindex*(cb.autosize_max_h + cb.margin) + cb.autosize_max_h/2), 0.1);
  237. <!-- when all is done, show the combobox -->
  238. delayedcall(0.1, set(global.layer[get(cb.name)].visible,true); );
  239. );
  240. </action>
  241. <!-- helper action for calling a plugin event-code with 'global' and 'caller' scope -->
  242. <action name="combobox_do_event_call" scope="local" args="cb, eventcode">
  243. if(eventcode !== null, callwith(cb, get(eventcode) ); );
  244. </action>
  245. <!-- default onclick event for items: select the current item, close the list and call the item onclick event -->
  246. <action name="combobox_item_onclick" scope="localonly">
  247. copy(cb, global.layer[get(caller.cblayername)]);
  248. copy(itemname, caller.itemname);
  249. combobox_selectitem(get(cb.name), get(itemname));
  250. if(global.openedcombobox === cb, combobox_closelist() );
  251. if(cb.item[get(itemname)].onclick,
  252. if(cb.callonclickafterclose === false,
  253. <!-- call instantly -->
  254. combobox_do_event_call(get(cb), get(cb.item[get(itemname)].onclick));
  255. ,
  256. <!-- call the onclick event after the combobox has closed -->
  257. delayedcall(get(cb.open_close_speed),
  258. copy(cb.curitem, cb.item[get(itemname)]);
  259. combobox_do_event_call(get(cb), get(cb.item[get(itemname)].onclick));
  260. );
  261. );
  262. );
  263. </action>
  264. <!-- select an item -->
  265. <action name="combobox_selectitem" scope="localonly" args="cbname, itemname">
  266. if(global.combbox_item_pressed != true,
  267. copy(cb, global.layer[get(cbname)]);
  268. copy(cb.lastselecteditemindex, cb.selecteditemindex);
  269. copy(cb.selecteditemindex, cb.item[get(itemname)].index);
  270. <!-- call onchange event on selection change -->
  271. if(cb.lastselecteditemindex != cb.selecteditemindex AND cb.onchange,
  272. combobox_do_event_call(get(cb), get(cb.onchange));
  273. );
  274. if(global.openedcombobox === cb,
  275. <!-- when opened, just close to the selected item -->
  276. combobox_closelist();
  277. ,
  278. if(global.layer[get(cbname)].scrollarea.loaded AND cb.autosize_max_h GT 0,
  279. global.layer[get(cbname)].scrollarea.stopscrolling();
  280. calc(offset, cb.selecteditemindex*(cb.autosize_max_h + cb.margin));
  281. tween(global.layer[get(cbname)].marker.y, calc(cb.margin + offset + cb.autosize_max_h/2), 0);
  282. tween(global.layer[get(cbname)].scrollarea.y, calc(-offset), 0, default, global.layer[get(cbname)].scrollarea.update(); );
  283. );
  284. );
  285. );
  286. </action>
  287. <!-- find an item by its caption, the global variable defined in 'returnvariable' will contain the index -->
  288. <action name="combobox_finditem" scope="localonly" args="cbname, itemcaption, returnvariable">
  289. copy(cb, global.layer[get(cbname)]);
  290. copy(item_cnt, cb.item.count);
  291. set(calc('global.' + returnvariable), -1);
  292. for(def(item_i, integer, 0), item_i LT item_cnt, inc(item_i),
  293. if(cb.item[get(item_i)].caption == itemcaption,
  294. copy(calc('global.' + returnvariable), item_i);
  295. copy(item_i, item_cnt);
  296. );
  297. );
  298. </action>
  299. <!-- remove all items (to be able to add new ones) -->
  300. <action name="combobox_removeitems" scope="localonly" args="cbname">
  301. copy(cb, global.layer[get(cbname)]);
  302. if(global.openedcombobox === cb, combobox_closelist() );
  303. <!-- remove all item layers -->
  304. calc(item_i, cb.item.count - 1);
  305. loop(item_i GE 0,
  306. removelayer(get(cb.item[get(item_i)].itemlayername));
  307. dec(item_i);
  308. );
  309. <!-- reset the item information -->
  310. set(cb.item.count, 0);
  311. set(cb.autosize_i,0);
  312. set(cb.autosize_cnt, 0);
  313. set(cb.autosize_max_w, 0);
  314. set(cb.autosize_max_h, 0);
  315. set(cb.selecteditemindex, 0);
  316. set(cb.lastselecteditemindex, 0);
  317. if(cb.width == cb.lastautosizedwidth, set(cb.width, null));
  318. </action>
  319. <!-- open the combobox list -->
  320. <action name="combobox_openlist" scope="localonly" args="cbname">
  321. <!-- if another combobox is already open, close that one first -->
  322. if(global.openedcombobox !== null, combobox_closelist() );
  323. copy(cb, global.layer[get(cbname)]);
  324. copy(global.openedcombobox, cb);
  325. <!-- move to top -->
  326. copy(cb.backupzorder, cb.zorder);
  327. set(cb.zorder, 999);
  328. <!-- find the available screen space above or below the combobox -->
  329. calc(cbheight, 2*cb.margin + cb.autosize_max_h);
  330. set(lx1, 0);
  331. set(ly1, 0);
  332. copy(lx2, cb.pixelwidth);
  333. copy(ly2, cbheight);
  334. layertoscreen(get(cbname), lx1,ly1, lx1,ly1);
  335. layertoscreen(get(cbname), lx2,ly2, lx2,ly2);
  336. calc(space_above, ly1 - global.area.pixely);
  337. calc(space_below, global.area.pixelheight - (ly2 - global.area.pixely));
  338. <!-- the required space for full opening: -->
  339. calc(openheight, cb.margin + cb.autosize_cnt*(cb.margin+cb.autosize_max_h) );
  340. <!-- vertical centered alignment? -->
  341. calc(cb_edge, cb.edge ? cb.edge : cb.align);
  342. calc(iscentered, cb_edge == 'left' OR cb_edge == 'center' OR cb_edge == 'right');
  343. if(iscentered,
  344. calc(openheight_max, space_above + space_below);
  345. ,
  346. Math.max(openheight_max, space_above, space_below);
  347. );
  348. <!-- limit the height to the available space (minus some margin) -->
  349. Math.min(openheight, calc(openheight_max + cbheight - 20));
  350. clamp(openheight, 0, get(cb.maxopenheight));
  351. <!-- need vertical offset? (depending on the available space and the align/edge setting) -->
  352. set(yoffset, null);
  353. calc(top_overflow, -ly1 + global.area.pixely + openheight/2);
  354. calc(bottom_overflow, ly2 - global.area.pixely + openheight/2 - global.area.pixelheight);
  355. if(cb.parentobject AND cb.parentobject.autoheight == false,
  356. <!-- no vertical offset inside other layers, do only a height clipping -->
  357. Math.max(max_overflow, top_overflow, bottom_overflow, 0);
  358. sub(openheight, max_overflow);
  359. ,
  360. if(iscentered,
  361. if(openheight GE (global.area.pixelheight - 20),
  362. set(yoffset,0);
  363. ,
  364. if(top_overflow GT 0, calc(yoffset, cb.y + top_overflow); );
  365. if(bottom_overflow GT 0, calc(yoffset, cb.y - bottom_overflow); );
  366. );
  367. ,
  368. indexoftxt(isbottomalign, get(cb_edge), 'bottom');
  369. if(space_above GT space_below,
  370. if(isbottomalign LT 0, calc(yoffset, cb.y - openheight + cbheight); );
  371. ,
  372. if(isbottomalign GE 0, calc(yoffset, cb.y - openheight + cbheight); );
  373. );
  374. );
  375. );
  376. if(yoffset != null,
  377. copy(cb.ybackup, cb.y);
  378. tween(global.layer[get(cbname)].y, calc(yoffset), get(cb.open_close_speed));
  379. );
  380. <!-- center the opened list at the selected item -->
  381. if( indexof(cb_edge,'top') GE 0,
  382. calc(centeritem_y, -1 * (cb.margin + cb.selecteditemindex*(cb.margin+cb.autosize_max_h) - cb.margin));
  383. clamp(centeritem_y, calc(openheight - cb.scrollarea.height), 0);
  384. ,
  385. indexof(cb_edge,'bottom') GE 0,
  386. calc(centeritem_y, -1 * (cb.margin + cb.selecteditemindex*(cb.margin+cb.autosize_max_h) + cb.autosize_max_h - openheight + cb.margin));
  387. clamp(centeritem_y, calc(openheight - cb.scrollarea.height), 0);
  388. ,
  389. calc(centeritem_y, -1 * (cb.margin + cb.selecteditemindex*(cb.margin+cb.autosize_max_h) + cb.autosize_max_h/2 - openheight/2));
  390. clamp(centeritem_y, calc(openheight - cb.scrollarea.height), 0);
  391. );
  392. <!-- apply the changes now -->
  393. tween(global.layer[get(cbname)].height, get(openheight), get(cb.open_close_speed));
  394. tween(global.layer[get(cbname)].scrollarea.y, get(centeritem_y), get(cb.open_close_speed), default, global.layer[get(cbname)].scrollarea.update(); );
  395. tween(global.layer[get(cbname)].marker.rotate, 90, get(cb.open_close_speed));
  396. <!-- enable the scrollarea to allow the user to drag it -->
  397. set(cb.scrollarea.enabled, true);
  398. <!-- install a global onmousedown event to close the list when clicking at the pano -->
  399. set(global.events[combobox_xml_plugin_events].onmousedown, combobox_closelist() );
  400. </action>
  401. <!-- close the current open list -->
  402. <action name="combobox_closelist" scope="localonly">
  403. if(global.openedcombobox !== null,
  404. copy(cb, global.openedcombobox);
  405. delete(global.openedcombobox);
  406. <!-- restore zorder -->
  407. copy(cb.zorder, cb.backupzorder);
  408. <!-- clear the global onmousedown event -->
  409. set(global.events[combobox_xml_plugin_events].onmousedown, null);
  410. <!-- disable the dragging -->
  411. set(cb.scrollarea.enabled, false);
  412. <!-- closing animations -->
  413. calc(offset, cb.selecteditemindex*(cb.autosize_max_h + cb.margin));
  414. if(cb.ybackup !== null, tween(cb.y, get(cb.ybackup), get(cb.open_close_speed)));
  415. global.layer[get(cb.name)].scrollarea.stopscrolling();
  416. tween(global.layer[get(cb.name)].height, calc(2*cb.margin + cb.autosize_max_h), get(cb.open_close_speed));
  417. tween(global.layer[get(cb.name)].scrollarea.y, calc(-offset), get(cb.open_close_speed), default, global.layer[get(cb.name)].scrollarea.update(); );
  418. tween(global.layer[get(cb.name)].marker.y, calc(cb.margin + offset + cb.autosize_max_h/2), get(cb.open_close_speed));
  419. tween(global.layer[get(cb.name)].marker.rotate, 0, get(cb.open_close_speed));
  420. );
  421. </action>
  422. </krpano>