mirror of
https://github.com/overte-org/overte.git
synced 2025-06-03 12:51:16 +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"
|
placeholderText: "Username or Email"
|
||||||
activeFocusOnPress: true
|
activeFocusOnPress: true
|
||||||
|
prohibitedCharacters: ["\n"];
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case Qt.Key_Tab:
|
case Qt.Key_Tab:
|
||||||
|
@ -315,6 +316,7 @@ Item {
|
||||||
styleRenderType: Text.QtRendering
|
styleRenderType: Text.QtRendering
|
||||||
placeholderText: "Password"
|
placeholderText: "Password"
|
||||||
activeFocusOnPress: true
|
activeFocusOnPress: true
|
||||||
|
prohibitedCharacters: ["\n"];
|
||||||
echoMode: passwordFieldMouseArea.showPassword ? TextInput.Normal : TextInput.Password
|
echoMode: passwordFieldMouseArea.showPassword ? TextInput.Normal : TextInput.Password
|
||||||
anchors {
|
anchors {
|
||||||
top: emailField.bottom
|
top: emailField.bottom
|
||||||
|
|
|
@ -32,6 +32,7 @@ TextField {
|
||||||
property string leftPermanentGlyph: "";
|
property string leftPermanentGlyph: "";
|
||||||
property string centerPlaceholderGlyph: "";
|
property string centerPlaceholderGlyph: "";
|
||||||
property int styleRenderType: Text.NativeRendering
|
property int styleRenderType: Text.NativeRendering
|
||||||
|
property var prohibitedCharacters: [""];
|
||||||
|
|
||||||
placeholderText: textField.placeholderText
|
placeholderText: textField.placeholderText
|
||||||
|
|
||||||
|
@ -179,4 +180,15 @@ TextField {
|
||||||
anchors.bottomMargin: 3
|
anchors.bottomMargin: 3
|
||||||
visible: label != ""
|
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