Select.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /************************************************************************
  2. * Select.js
  3. ************************************************************************
  4. * Copyright (c) 2021 Pedro Tonini Rosenberg Schneider.
  5. *
  6. * This file is part of Pandora.
  7. *
  8. * Pandora is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Pandora is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with Pandora. If not, see <https://www.gnu.org/licenses/>.
  20. *************************************************************************/
  21. class Select extends UIObject
  22. {
  23. constructor(name)
  24. {
  25. super(name);
  26. this.P5Element = createSelect();
  27. this.setPosition(0, 0);
  28. this.setSize(100, 20);
  29. this.setStyle(DEFAULT_STYLE);
  30. this.connectCallbacks();
  31. this.P5Element.changed(this.onChanged);
  32. }
  33. // Setters
  34. setSelected(value)
  35. {
  36. this.P5Element.selected(value);
  37. }
  38. // Getters
  39. getSelected()
  40. {
  41. return this.P5Element.selected();
  42. }
  43. // Methods
  44. addOption(value)
  45. {
  46. this.P5Element.option(value);
  47. }
  48. // TODO confirm if disable methods really dont exist or if
  49. // something is fucky wooky.
  50. // disableAll()
  51. // {
  52. // this.P5Element.disable();
  53. // }
  54. // disableOption(value)
  55. // {
  56. // this.P5Element.disable(value);
  57. // }
  58. // Callbacks
  59. _onChanged()
  60. {
  61. }
  62. onChanged()
  63. {
  64. this.pandoraObject._onChanged();
  65. }
  66. }