combobox.adoc 2.1 KB

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