combobox.adoc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. = combobox
  2. :revnumber: 2.0
  3. :revdate: 2020/07/25
  4. == SelectBox & ComboBox
  5. The combo box and select box works exactly like any other combo box or select box:
  6. * They both provides the standard 3 constructors
  7. * The only difference between the two is the SelectBox’s text field is disabled.
  8. * The SelectBox still allows for arrow key navigation and enter select, though other key input is disabled.
  9. === Usage is as follows:
  10. [source,java]
  11. ----
  12. ComboBox combo = new ComboBox(
  13. screen,
  14. "SomeID",
  15. new Vector2f(5,5)
  16. );
  17. combo.addListItem("Some caption", "Some value");
  18. combo.addListItem("Some caption", "Some value");
  19. combo.addListItem("Some caption", "Some value");
  20. combo.addListItem("Some caption", "Some value");
  21. combo.addListItem("Some caption", "Some value");
  22. combo.addListItem("Some caption", "Some value");
  23. ----
  24. === Abstract Event Methods:
  25. [source,java]
  26. ----
  27. public void onChange(int selectedIndex, String value);
  28. ----
  29. === Hooks:
  30. [source,java]
  31. ----
  32. // Overridable hook for keyboard input events
  33. public void controlKeyPressHook(KeyInputEvent evt, String text) { }
  34. ----
  35. === Set Selected Index via Code
  36. [source,java]
  37. ----
  38. combo.setSelectedIndex(int index);
  39. combo.getSelectedIndex();
  40. ----
  41. === Methods specific to Combo & Select Boxes:
  42. [source,java]
  43. ----
  44. // Add a list item
  45. combo.addListItem(String caption, String value);
  46. // Insert a list item
  47. combo.insertListItem(int index, String caption, Object value);
  48. // Remove a list item
  49. combo.removeListItem(int index);
  50. combo.removeListItem(String caption);
  51. combo.removeListIten(Object value);
  52. // Sorting methods
  53. combo.sortList(); // Sorts drop-down list standard alpha-numeric
  54. combo.sortListNumeric(); // Sorts drop-down list true numeric
  55. // Drop-down list validation
  56. combo.validateListSize(); //returns false if null or size 0, else returns true;
  57. // Force drop-down list to hide
  58. combo.hideDropDownList();
  59. // Retrieve List Items
  60. combo.getSelectedListItem();
  61. combo.getListItemByIndex(int index);
  62. ----