customToolboxGui.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. Sandbox.customLabelHeight = "15";
  23. Sandbox.customLabelWidth = "220";
  24. Sandbox.customLabelSpacing = "18";
  25. Sandbox.customOptionSpacing = "15";
  26. Sandbox.customContainerExtent = "250 3";
  27. Sandbox.containerXPosition = "20";
  28. Sandbox.flagOptionExtent = "240 30";
  29. Sandbox.buttonOptionExtent = "240 35";
  30. Sandbox.spinnerExtent = "22 25";
  31. Sandbox.intOptionExtent = "196 25";
  32. Sandbox.listOptionExtent = "240 0";
  33. Sandbox.customControlCount = "0";
  34. Sandbox.lastControlBottom = "0";
  35. //-----------------------------------------------------------------------------
  36. function resetCustomControls()
  37. {
  38. Sandbox.lastControlBottom = "0";
  39. Sandbox.customControlCount = 0;
  40. %customControlExtent = ToyCustomControls.Extent;
  41. %newExtent = getWord(ToyCustomControls.Extent, 0) SPC 705;
  42. ToyCustomControls.Extent = %newExtent;
  43. CustomControlsScroller.computeSizes();
  44. }
  45. //-----------------------------------------------------------------------------
  46. function createCustomLabel(%text)
  47. {
  48. %labelWidth = Sandbox.customLabelWidth + (%characterCount * 5);
  49. %labelExtent = %labelWidth SPC Sandbox.customLabelHeight;
  50. %labelControl = new GuiControl()
  51. {
  52. text = %text;
  53. Extent = %labelExtent;
  54. HorizSizing = "relative";
  55. VertSizing = "relative";
  56. Profile = "GuiLabelProfile";
  57. canSaveDynamicFields = "0";
  58. isContainer = "0";
  59. Position = "3 0";
  60. MinExtent = "8 2";
  61. canSave = "0";
  62. Visible = "1";
  63. Active = "0";
  64. tooltipprofile = "GuiToolTipProfile";
  65. tooltipWidth = "0";
  66. maxLength = "255";
  67. truncate = "0";
  68. };
  69. return %labelControl;
  70. }
  71. //-----------------------------------------------------------------------------
  72. function nextCustomControlPosition(%index)
  73. {
  74. %verticalOffset = (Sandbox.customOptionSpacing + %index) + Sandbox.lastControlBottom;
  75. %position = Sandbox.containerXPosition SPC %verticalOffset;
  76. return %position;
  77. }
  78. //-----------------------------------------------------------------------------
  79. function addFlagOption( %label, %callback, %startingValue, %shouldReset, %tooltipText)
  80. {
  81. %containerPosition = nextCustomControlPosition(Sandbox.customControlCount);
  82. %customX = getWord(Sandbox.customContainerExtent, 0);
  83. %customY = getWord(Sandbox.customContainerExtent, 1) + getWord(Sandbox.flagOptionExtent, 1);
  84. %container = new GuiControl()
  85. {
  86. isContainer = 1;
  87. position = %containerPosition;
  88. extent = %customX SPC %customY;
  89. Profile = GuiTransparentProfile;
  90. HorizSizing = "relative";
  91. VertSizing = "relative";
  92. };
  93. %button = new GuiCheckBoxCtrl()
  94. {
  95. canSaveDynamicFields = "0";
  96. HorizSizing = "relative";
  97. VertSizing = "relative";
  98. isContainer = "0";
  99. Profile = "GuiCheckBoxProfile";
  100. Position = "0 0";
  101. Extent = Sandbox.flagOptionExtent;
  102. Visible = "1";
  103. toy = Sandbox.ActiveToy.ScopeSet;
  104. shouldResetToy = %shouldReset;
  105. callback = %callback;
  106. class = "FlagController";
  107. isContainer = "0";
  108. Active = "1";
  109. hovertime = "1000";
  110. toolTipProfile = "GuiToolTipProfile";
  111. toolTip = %tooltipText;
  112. text = %label;
  113. };
  114. %button.setStateOn(%startingValue);
  115. %button.command = %button @ ".updateToy();";
  116. %container.add(%button);
  117. ToyCustomControls.add(%container);
  118. Sandbox.lastControlBottom = getWord(%container.position, 1) + getWord(%container.extent, 1);
  119. if (Sandbox.lastControlBottom > getWord(ToyCustomControls.Extent, 1))
  120. {
  121. %rootContainerExtent = getWord(ToyCustomControls.Extent, 0) SPC Sandbox.lastControlBottom + 20;
  122. ToyCustomControls.Extent = %rootContainerExtent;
  123. CustomControlsScroller.computeSizes();
  124. }
  125. Sandbox.customControlCount++;
  126. }
  127. //-----------------------------------------------------------------------------
  128. function FlagController::updateToy(%this)
  129. {
  130. if (%this.toy $= "")
  131. return;
  132. if (%this.callback !$= "")
  133. {
  134. %setter = "%this.toy." @ %this.callback @ "(" @ %this.getStateOn() @ ");";
  135. eval(%setter);
  136. }
  137. if (%this.shouldResetToy && %this.toy.isMethod("reset"))
  138. %this.toy.reset();
  139. }
  140. //-----------------------------------------------------------------------------
  141. function addButtonOption( %label, %callback, %shouldReset, %tooltipText)
  142. {
  143. %containerPosition = nextCustomControlPosition(Sandbox.customControlCount);
  144. %customX = getWord(Sandbox.customContainerExtent, 0);
  145. %customY = getWord(Sandbox.customContainerExtent, 1) + getWord(Sandbox.buttonOptionExtent, 1);
  146. %container = new GuiControl()
  147. {
  148. isContainer = 1;
  149. HorizSizing = "relative";
  150. VertSizing = "relative";
  151. position = %containerPosition;
  152. extent = %customX SPC %customY;
  153. Profile = GuiTransparentProfile;
  154. };
  155. %button = new GuiButtonCtrl()
  156. {
  157. canSaveDynamicFields = "0";
  158. HorizSizing = "relative";
  159. VertSizing = "relative";
  160. isContainer = "0";
  161. Profile = "BlueButtonProfile";
  162. Position = "0 0";
  163. Extent = Sandbox.buttonOptionExtent;
  164. Visible = "1";
  165. toy = Sandbox.ActiveToy.ScopeSet;
  166. shouldResetToy = %shouldReset;
  167. callback = %callback;
  168. class = "ButtonController";
  169. isContainer = "0";
  170. Active = "1";
  171. hovertime = "1000";
  172. toolTipProfile = "GuiToolTipProfile";
  173. toolTip = %tooltipText;
  174. text = %label;
  175. groupNum = "-1";
  176. buttonType = "PushButton";
  177. useMouseEvents = "0";
  178. };
  179. %button.command = %button @ ".updateToy();";
  180. %container.add(%button);
  181. ToyCustomControls.add(%container);
  182. Sandbox.lastControlBottom = getWord(%container.position, 1) + getWord(%container.extent, 1);
  183. if (Sandbox.lastControlBottom > getWord(ToyCustomControls.Extent, 1))
  184. {
  185. %rootContainerExtent = getWord(ToyCustomControls.Extent, 0) SPC Sandbox.lastControlBottom + 20;
  186. ToyCustomControls.Extent = %rootContainerExtent;
  187. CustomControlsScroller.computeSizes();
  188. }
  189. Sandbox.customControlCount++;
  190. }
  191. //-----------------------------------------------------------------------------
  192. function ButtonController::updateToy(%this)
  193. {
  194. if (%this.toy $= "")
  195. return;
  196. if (%this.callback !$= "")
  197. {
  198. %setter = "%this.toy." @ %this.callback @ "();";
  199. eval(%setter);
  200. }
  201. if (%this.shouldResetToy && %this.toy.isMethod("reset"))
  202. %this.toy.reset();
  203. }
  204. //-----------------------------------------------------------------------------
  205. function addNumericOption( %label, %min, %max, %step, %callback, %startingValue, %shouldReset, %tooltipText)
  206. {
  207. %customLabel = createCustomLabel(%label);
  208. %containerPosition = nextCustomControlPosition(Sandbox.customControlCount);
  209. %customX = getWord(Sandbox.customContainerExtent, 0);
  210. %customY = getWord(Sandbox.customContainerExtent, 1) + getWord(Sandbox.intOptionExtent, 1) + Sandbox.customLabelHeight;
  211. %container = new GuiControl()
  212. {
  213. isContainer = 1;
  214. position = %containerPosition;
  215. HorizSizing = "relative";
  216. VertSizing = "relative";
  217. extent = %customX SPC %customY;
  218. Profile = GuiTransparentProfile;
  219. };
  220. %container.add(%customLabel);
  221. %spinnerPosition = "1" SPC Sandbox.customLabelSpacing;
  222. %spinnerDown = new GuiButtonCtrl()
  223. {
  224. Action = "decrease";
  225. Class = "SpinnerController";
  226. Step = %step;
  227. HorizSizing = "relative";
  228. VertSizing = "relative";
  229. canSaveDynamicFields = "0";
  230. isContainer = "0";
  231. Profile = "GuiMinusButtonProfile";
  232. Position = %spinnerPosition;
  233. Extent = Sandbox.spinnerExtent;
  234. MinExtent = "22 25";
  235. canSave = "1";
  236. Visible = "1";
  237. Active = "1";
  238. hovertime = "1000";
  239. toolTipProfile = "GuiToolTipProfile";
  240. toolTip = %tooltipText;
  241. text = "";
  242. };
  243. %controlPosition = (getWord(Sandbox.spinnerExtent, 0) + 1) SPC Sandbox.customLabelSpacing;
  244. %textEdit = new GuiTextEditCtrl()
  245. {
  246. Position = %controlPosition;
  247. HorizSizing = "relative";
  248. VertSizing = "relative";
  249. min = %min;
  250. max = %max;
  251. Text = %startingValue;
  252. Extent = Sandbox.intOptionExtent;
  253. toy = Sandbox.ActiveToy.ScopeSet;
  254. shouldResetToy = %shouldReset;
  255. callback = %callback;
  256. class = "TextEditController";
  257. isContainer = "0";
  258. Profile = "GuiSpinnerProfile";
  259. toolTipProfile = "GuiToolTipProfile";
  260. toolTip = %tooltipText;
  261. hovertime = "1000";
  262. };
  263. %spinnerPosition = (getWord(%textEdit.Extent, 0) + getWord(%textEdit.position, 0)) SPC Sandbox.customLabelSpacing;
  264. %spinnerUp = new GuiButtonCtrl()
  265. {
  266. Action = "increase";
  267. HorizSizing = "relative";
  268. VertSizing = "relative";
  269. Class = "SpinnerController";
  270. Step = %step;
  271. canSaveDynamicFields = "0";
  272. isContainer = "0";
  273. Profile = "GuiPlusButtonProfile";
  274. Position = %spinnerPosition;
  275. Extent = Sandbox.spinnerExtent;
  276. MinExtent = "22 25";
  277. canSave = "1";
  278. Visible = "1";
  279. Active = "1";
  280. hovertime = "1000";
  281. toolTipProfile = "GuiToolTipProfile";
  282. toolTip = %tooltipText;
  283. text = "";
  284. };
  285. %textEdit.validate = %textEdit @ ".updateToy();";
  286. %spinnerDown.target = %textEdit;
  287. %spinnerUp.target = %textEdit;
  288. %spinnerDown.command = %spinnerDown @ ".updateTarget();";
  289. %spinnerUp.command = %spinnerUp @ ".updateTarget();";
  290. %container.add(%spinnerDown);
  291. %container.add(%textEdit);
  292. %container.add(%spinnerUp);
  293. ToyCustomControls.add(%container);
  294. Sandbox.lastControlBottom = getWord(%container.position, 1) + getWord(%container.extent, 1);
  295. if (Sandbox.lastControlBottom > getWord(ToyCustomControls.Extent, 1))
  296. {
  297. %rootContainerExtent = getWord(ToyCustomControls.Extent, 0) SPC Sandbox.lastControlBottom + 20;
  298. ToyCustomControls.Extent = %rootContainerExtent;
  299. CustomControlsScroller.computeSizes();
  300. }
  301. Sandbox.customControlCount++;
  302. }
  303. //-----------------------------------------------------------------------------
  304. function SpinnerController::updateTarget(%this)
  305. {
  306. %target = %this.target;
  307. if (%this.action $= "increase")
  308. {
  309. %value = %target.getText();
  310. %value += %this.step;
  311. if (%value > %target.max)
  312. %value = %target.max;
  313. %target.setText(%value);
  314. }
  315. else if (%this.action $= "decrease")
  316. {
  317. %value = %target.getText();
  318. %value -= %this.step;
  319. if (%value < %target.min)
  320. %value = %target.min;
  321. %target.setText(%value);
  322. }
  323. %target.updateToy();
  324. }
  325. //-----------------------------------------------------------------------------
  326. function TextEditController::updateToy(%this)
  327. {
  328. if (%this.toy $= "")
  329. return;
  330. if (%this.getText() > %this.max)
  331. %this.setText(%this.max);
  332. else if (%this.getText() < %this.min)
  333. %this.setText(%this.min);
  334. if (%this.callback !$= "" && %this.getValue() !$= "")
  335. {
  336. %setter = "%this.toy." @ %this.callback @ "(" @ %this.getValue() @ ");";
  337. eval(%setter);
  338. }
  339. if (%this.shouldResetToy && %this.toy.isMethod("reset"))
  340. %this.toy.reset();
  341. }
  342. //-----------------------------------------------------------------------------
  343. function addSelectionOption( %entries, %label, %maxDisplay, %callback, %shouldReset, %tooltipText)
  344. {
  345. // Combined Y extent of the up/down buttons
  346. %buttonExtentAddition = 46;
  347. // Extra padding
  348. %buffer = 15;
  349. // Size of each button added to the list
  350. %buttonSize = 50;
  351. %buttonSpacing = %maxDisplay;// * 8;
  352. // Starting location of the main container
  353. %containerPosition = nextCustomControlPosition(Sandbox.customControlCount);
  354. // Main container base width
  355. %containerWidth = getWord(Sandbox.customContainerExtent, 0);
  356. // Main container base height
  357. %containerHeight = getWord(Sandbox.customContainerExtent, 1) + getWord(Sandbox.listOptionExtent, 1) + Sandbox.customLabelHeight;
  358. // Main container buffer (accounts for size of list, up/down buttons, and buffer)
  359. %containerHeight += ((%maxDisplay+1) * %buttonSize) + %buttonExtentAddition + %buffer;
  360. // X position of buttons
  361. %buttonX = "90";
  362. // Y position for up button
  363. %upButtonY = Sandbox.customLabelSpacing;
  364. // List container
  365. %listContainerPosition = "0" SPC %upButtonY + 22;
  366. %listContainerWidth = %containerWidth;
  367. %listContainerHeight = ((%maxDisplay+1) * %buttonSize) + %buttonSpacing;
  368. %scrollContainerWidth = %listContainerWidth - 5;
  369. %scrollContainerHeight = %listContainerHeight;
  370. // Array control
  371. %arrayListWidth = %scrollContainerWidth - 25;
  372. %arrayListHeight = 0;
  373. // Y position for the down button
  374. %downButtonY = getWord(%listContainerPosition, 1) + %listContainerHeight;
  375. // Create the base container
  376. %container = new GuiControl()
  377. {
  378. isContainer = 1;
  379. HorizSizing = "relative";
  380. VertSizing = "relative";
  381. position = %containerPosition;
  382. extent = %containerWidth SPC %containerHeight;
  383. Profile = GuiTransparentProfile;
  384. };
  385. // Create and add the text label
  386. %customLabel = createCustomLabel(%label);
  387. %container.add(%customLabel);
  388. %listContainer = new GuiControl()
  389. {
  390. isContainer = 1;
  391. HorizSizing = "relative";
  392. VertSizing = "relative";
  393. position = %listContainerPosition;
  394. extent = %listContainerWidth SPC %listContainerHeight;
  395. Profile = GuiSunkenContainerProfile;
  396. };
  397. %scrollControl = new GuiScrollCtrl()
  398. {
  399. canSaveDynamicFields = "1";
  400. isContainer = "1";
  401. class = "CustomScrollControl";
  402. Profile = "GuiScrollProfile";
  403. ThumbProfile = "GuiScrollThumbProfile";
  404. TrackProfile = "GuiScrollTrackProfile";
  405. ArrowProfile = "GuiScrollArrowProfile";
  406. HorizSizing = "relative";
  407. VertSizing = "relative";
  408. Position = "3 3";
  409. Extent = %scrollContainerWidth SPC %scrollContainerHeight;
  410. MinExtent = %scrollContainerWidth SPC %scrollContainerHeight;
  411. canSave = "1";
  412. Visible = "1";
  413. Active = "1";
  414. hovertime = "1000";
  415. willFirstRespond = "1";
  416. hScrollBar = "alwaysOn";
  417. vScrollBar = "alwaysOn";
  418. constantThumbHeight = "0";
  419. childMargin = "2 3";
  420. toolTipProfile = "GuiToolTipProfile";
  421. toolTip = %tooltipText;
  422. };
  423. %arrayList = new GuiGridCtrl()
  424. {
  425. canSaveDynamicFields = "0";
  426. isContainer = "1";
  427. class = "CustomOptionArrayClass";
  428. Profile = "GuiTransparentProfile";
  429. HorizSizing = "relative";
  430. VertSizing = "relative";
  431. Position = "0 1";
  432. Extent = %arrayListWidth SPC %arrayListHeight;
  433. MinExtent = "1 2";
  434. canSave = "1";
  435. Visible = "1";
  436. Active = "1";
  437. tooltipprofile = "GuiToolTipProfile";
  438. hovertime = "1000";
  439. MaxColCount = "1";
  440. CellSizeX = %arrayListWidth-10;
  441. CellSizeY = "50";
  442. CellSpacingX = "8";
  443. CellSpacingY = "8";
  444. CellModeX = "variable";
  445. toolTipProfile = "GuiToolTipProfile";
  446. toolTip = %tooltipText;
  447. };
  448. %scrollControl.add(%arrayList);
  449. %listContainer.add(%scrollControl);
  450. %container.add(%listContainer);
  451. // Populate the list
  452. for (%i = 0; %i < getUnitCount(%entries, ","); %i++)
  453. {
  454. %button = new GuiButtonCtrl()
  455. {
  456. canSaveDynamicFields = "0";
  457. class = "SelectionController";
  458. toy = Sandbox.ActiveToy.ScopeSet;
  459. shouldResetToy = %shouldReset;
  460. callback = %callback;
  461. HorizSizing = "relative";
  462. VertSizing = "relative";
  463. isContainer = "0";
  464. Profile = "BlueButtonProfile";
  465. Position = "0 0";
  466. Extent = "160 80";
  467. Visible = "1";
  468. isContainer = "0";
  469. Active = "1";
  470. text = getUnit(%entries, %i, ",");
  471. groupNum = "1";
  472. buttonType = "ToggleButton";
  473. useMouseEvents = "0";
  474. toolTipProfile = "GuiToolTipProfile";
  475. toolTip = %tooltipText;
  476. };
  477. %button.command = %arrayList @ ".clearSelections();" @ %button @ ".updateToy();";
  478. %arrayList.add(%button);
  479. }
  480. // Create and add the up button
  481. %upButton = new GuiButtonCtrl()
  482. {
  483. canSaveDynamicFields = "0";
  484. isContainer = "0";
  485. Profile = "GuiNorthButtonProfile";
  486. HorizSizing = "relative";
  487. VertSizing = "relative";
  488. Position = %buttonX SPC %upButtonY;
  489. Extent = "69 23";
  490. MinExtent = "12 4";
  491. canSave = "1";
  492. Visible = "1";
  493. Active = "1";
  494. text = "";
  495. toolTipProfile = "GuiToolTipProfile";
  496. toolTip = %tooltipText;
  497. };
  498. %upButton.command = %scrollControl @ ".scrollToPrevious();";
  499. // Create and add the down button
  500. %downButton = new GuiButtonCtrl()
  501. {
  502. canSaveDynamicFields = "0";
  503. isContainer = "0";
  504. Profile = "GuiSouthButtonProfile";
  505. HorizSizing = "relative";
  506. VertSizing = "relative";
  507. Position = %buttonX SPC %downButtonY;
  508. Extent = "69 23";
  509. MinExtent = "12 4";
  510. canSave = "1";
  511. Visible = "1";
  512. Active = "1";
  513. text = "";
  514. toolTipProfile = "GuiToolTipProfile";
  515. toolTip = %tooltipText;
  516. };
  517. %downButton.command = %scrollControl @ ".scrollToNext();";
  518. %container.add(%upButton);
  519. %container.add(%downButton);
  520. ToyCustomControls.add(%container);
  521. Sandbox.lastControlBottom = getWord(%container.position, 1) + getWord(%container.extent, 1);
  522. if (Sandbox.lastControlBottom > getWord(ToyCustomControls.Extent, 1))
  523. {
  524. %rootContainerExtent = getWord(ToyCustomControls.Extent, 0) SPC Sandbox.lastControlBottom + 20;
  525. ToyCustomControls.Extent = %rootContainerExtent;
  526. CustomControlsScroller.computeSizes();
  527. }
  528. Sandbox.customControlCount++;
  529. }
  530. function CustomOptionArrayClass::clearSelections(%this)
  531. {
  532. %count = %this.getCount();
  533. for (%i = 0; %i < %count; %i++)
  534. {
  535. %button = %this.getObject(%i);
  536. %button.setStateOn(false);
  537. }
  538. }
  539. //-----------------------------------------------------------------------------
  540. function CustomScrollControl::scrollToNext(%this)
  541. {
  542. %currentScroll = %this.getScrollPositionY();
  543. %currentScroll += 55;
  544. %this.setScrollPosition(0, %currentScroll);
  545. }
  546. //-----------------------------------------------------------------------------
  547. function CustomScrollControl::scrollToPrevious(%this)
  548. {
  549. %currentScroll = %this.getScrollPositionY();
  550. %currentScroll -= 55;
  551. %this.setScrollPosition(0, %currentScroll);
  552. }
  553. //-----------------------------------------------------------------------------
  554. function SelectionController::updateToy(%this)
  555. {
  556. if (%this.toy $= "")
  557. return;
  558. %this.setStateOn(true);
  559. if (%this.callback !$= "")
  560. {
  561. %value = %this.getText();
  562. %setter = "%this.toy." @ %this.callback @ "(\"" @ %value @ "\");";
  563. eval(%setter);
  564. }
  565. if (%this.shouldResetToy && %this.toy.isMethod("reset"))
  566. %this.toy.reset();
  567. }