|
@@ -5,7 +5,14 @@
|
|
|
|
|
|
#include "input/TextInput.h"
|
|
|
|
|
|
-TextInput::TextInput() : active(false) {
|
|
|
+TextInput::TextInput() : limit(256), active(false) {
|
|
|
+}
|
|
|
+
|
|
|
+void TextInput::setLimit(int limit) {
|
|
|
+ TextInput::limit = limit;
|
|
|
+ while(input.getLength() > limit) {
|
|
|
+ input.removeBySwap(limit);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void TextInput::reset() {
|
|
@@ -44,7 +51,7 @@ void TextInput::onKeyEvent(int key, int scancode, int action, int mods) {
|
|
|
}
|
|
|
|
|
|
void TextInput::onCharEvent(unsigned int codepoint) {
|
|
|
- if(!active) {
|
|
|
+ if(!active || input.getLength() >= limit) {
|
|
|
return;
|
|
|
}
|
|
|
input.add(codepoint);
|