Prohibit characters option.

This commit is contained in:
armored-dragon 2025-04-22 19:43:54 -05:00
parent 3aed07517a
commit a92d25ccdf
No known key found for this signature in database
GPG key ID: C7207ACC3382AD8B
2 changed files with 14 additions and 0 deletions

View file

@ -282,6 +282,7 @@ Item {
}
placeholderText: "Username or Email"
activeFocusOnPress: true
prohibitedCharacters: ["\n"];
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Tab:
@ -315,6 +316,7 @@ Item {
styleRenderType: Text.QtRendering
placeholderText: "Password"
activeFocusOnPress: true
prohibitedCharacters: ["\n"];
echoMode: passwordFieldMouseArea.showPassword ? TextInput.Normal : TextInput.Password
anchors {
top: emailField.bottom

View file

@ -32,6 +32,7 @@ TextField {
property string leftPermanentGlyph: "";
property string centerPlaceholderGlyph: "";
property int styleRenderType: Text.NativeRendering
property var prohibitedCharacters: [""];
placeholderText: textField.placeholderText
@ -179,4 +180,15 @@ TextField {
anchors.bottomMargin: 3
visible: label != ""
}
onTextChanged: {
removeProhibitedCharacters();
}
function removeProhibitedCharacters() {
var pattern = prohibitedCharacters.join('');
var regex = new RegExp('[' + pattern + ']', 'g');
text = text.replace(regex, '');
}
}