Don't allow tabs or newlines

This commit is contained in:
Zach Fox 2018-02-20 13:06:10 -08:00
parent 9bde9f5a4f
commit eb29bdf5d2

View file

@ -947,8 +947,14 @@ Item {
wrapMode: TextEdit.Wrap;
activeFocusOnPress: true;
activeFocusOnTab: true;
// Workaround for no max length on TextAreas
onTextChanged: {
// Don't allow tabs or newlines
if ((/[\n\r\t]/g).test(text)) {
var cursor = cursorPosition;
text = text.replace(/[\n\r\t]/g, '');
cursorPosition = cursor-1;
}
// Workaround for no max length on TextAreas
if (text.length > maximumLength) {
var cursor = cursorPosition;
text = previousText;