spinner.adoc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. = spinner
  2. :revnumber: 2.0
  3. :revdate: 2020/07/25
  4. == Spinner Class
  5. The Spinner class provides:
  6. * A display area for the current step value
  7. * An increment button
  8. * A Decrement button
  9. * It can be set to cycle (when it reaches highest step value it cycles to index 0, and reversed for decrement.
  10. The Spinner class provides the same 3 common constructors as shown in the xref:gui/tonegodgui/quickstart.adoc[Quick Start Guide] with the addition of two extra parameters.
  11. * The orientation of the Spinner
  12. * A boolean flag enabling/disabling Spinner cycling.
  13. The additional parameter are appended to the existing parameter list for all 3 constructors, like so:
  14. [source,java]
  15. ----
  16. /**
  17. * Parameters:
  18. * Screen screen
  19. * String UID
  20. * Vector2f position
  21. * Spinner.Orientation orientation
  22. * boolean cycle
  23. */
  24. Spinner spinner1 = new Spinner(
  25. screen,
  26. "SomeID",
  27. new Vector2f(15, 15),
  28. Spinner.Orientation.HORIZONTAL,
  29. true
  30. );
  31. ----
  32. === Abstract Event Methods:
  33. [source,java]
  34. ----
  35. public void onChange(int selectedIndex, String value);
  36. ----
  37. === Methods specific to the Spinner class:
  38. [source,java]
  39. ----
  40. // Quickly set interval info for both button
  41. spinner1.setInterval(float callsPerSecond);
  42. // Adding removing list info
  43. spinner1.addStepValue(String value);
  44. spinner1.removeStepValue(String value);
  45. // Quickly populate step values with integers/floats
  46. spinner1.setStepIntegerRange(int min, int max, int inc);
  47. spinner1.setStepFloatRange(float min, float max, float inc);
  48. // Retrieval of current selected step
  49. spinner1.getSelectedIndex();
  50. ----
  51. You can set the select Spinner's displayed and selected value using:
  52. [source,java]
  53. ----
  54. spinner1.setSelectedIndex(int selectedIndex)
  55. ----