checkbox.adoc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. = checkbox
  2. :revnumber: 2.0
  3. :revdate: 2020/07/25
  4. == CheckBox Class
  5. * CheckBoxes extend the Button class and enable the Toggle setting
  6. * They provide a default label (which is only added if the label text is set).
  7. * They provide the abstract method onChange for executing code when the CheckBox is altered by the user.
  8. Again, the same three options for constructor are available as show in the xref:gui/tonegodgui/quickstart.adoc[Quick Start Guide].
  9. *Constructor 1:*
  10. [source,java]
  11. ----
  12. /** Parameters:
  13. * Screen screen,
  14. * String UID,
  15. * Vector2f position
  16. */
  17. CheckBox cb = new CheckBox(screen, "cb", new Vector2f(15, 15));
  18. ----
  19. *Constructor 2:*
  20. [source,java]
  21. ----
  22. /** Additional Parameter:
  23. * Vector2f dimensions */
  24. CheckBox cb = new CheckBox(screen, "cb", new Vector2f(15, 15),
  25. new Vector2f(25, 25)
  26. );
  27. ----
  28. *Constructor 3:*
  29. [source,java]
  30. ----
  31. /** Additional Parameters:
  32. * Vector4f resizeBorders,
  33. * String defaultImg
  34. */
  35. CheckBox cb = new CheckBox(screen, "cb", new Vector2f(15, 15), new Vector2f(25, 25),
  36. new Vector4f(3,3,3,3),
  37. "tonegod/gui/style/def/Button/checkbox_u_x.png"
  38. );
  39. ----
  40. === Hover State
  41. You can override the default hover state using the following method:
  42. [source,java]
  43. ----
  44. // Override the information used by the hover effect
  45. cb.setButtonHoverInfo(String imagePath, ColorRGBA textHoverColor);
  46. ----
  47. === Pressed State
  48. You can override the default pressed state using the following method:
  49. [source,java]
  50. ----
  51. // Override the information used by the pressed effect
  52. cb.setButtonPressedInfo(String imagePath, ColorRGBA textPressedColor);
  53. ----
  54. === Abstract Event Methods:
  55. [source,java]
  56. ----
  57. public void onChange(boolean isChecked);
  58. ----
  59. === Methods Specific to the CheckBox Class:
  60. [source,java]
  61. ----
  62. cb.setCheckboxText(String text);
  63. cb.getIsChecked();
  64. ----