mirror of
https://github.com/overte-org/overte.git
synced 2025-05-30 08:53:21 +02:00
Prohibit characters option.
This commit is contained in:
parent
3aed07517a
commit
a92d25ccdf
2 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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, '');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue