TextInput.h 576 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef TEXT_INPUT_H
  2. #define TEXT_INPUT_H
  3. #include "utils/List.h"
  4. class TextInput final {
  5. List<unsigned int> input;
  6. int cursor;
  7. int limit;
  8. bool active;
  9. public:
  10. TextInput();
  11. void setLimit(int limit);
  12. void reset();
  13. void setActive(bool b);
  14. void onKeyEvent(int key, int scancode, int action, int mods);
  15. void onCharEvent(unsigned int codepoint);
  16. template<int N>
  17. void toString(StringBuffer<N>& s) const {
  18. for(unsigned int c : input) {
  19. s.appendUnicode(c);
  20. }
  21. }
  22. int getCursor() const;
  23. };
  24. #endif