mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
Fixed control characters being included in TextInput and TextField
This commit is contained in:
parent
7b2306f58f
commit
aef6f7bd58
2 changed files with 18 additions and 9 deletions
|
@ -12,9 +12,14 @@ Jump to version:
|
||||||
|
|
||||||
## 6.2.0 (In Development)
|
## 6.2.0 (In Development)
|
||||||
|
|
||||||
|
### MLEM
|
||||||
|
Fixes
|
||||||
|
- Fixed control characters being included in TextInput
|
||||||
|
|
||||||
### MLEM.Ui
|
### MLEM.Ui
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed images not updating their hidden state properly when the displayed texture changes
|
- Fixed images not updating their hidden state properly when the displayed texture changes
|
||||||
|
- Fixed control characters being included in TextField
|
||||||
|
|
||||||
## 6.1.0
|
## 6.1.0
|
||||||
|
|
||||||
|
|
|
@ -415,16 +415,20 @@ namespace MLEM.Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool FilterText(ref string text, bool removeMismatching) {
|
private bool FilterText(ref string text, bool removeMismatching) {
|
||||||
if (removeMismatching) {
|
var result = new StringBuilder();
|
||||||
var result = new StringBuilder();
|
foreach (var codePoint in new CodePointSource(text)) {
|
||||||
foreach (var codePoint in new CodePointSource(text)) {
|
var character = char.ConvertFromUtf32(codePoint);
|
||||||
var character = char.ConvertFromUtf32(codePoint);
|
// don't include control characters
|
||||||
if (this.InputRule(this, character))
|
if (character.Length == 1 && char.IsControl(character, 0))
|
||||||
result.Append(character);
|
continue;
|
||||||
|
if (this.InputRule(this, character)) {
|
||||||
|
result.Append(character);
|
||||||
|
} else if (!removeMismatching) {
|
||||||
|
// if we don't remove mismatching characters, we just fail
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
text = result.ToString();
|
}
|
||||||
} else if (!this.InputRule(this, text))
|
text = result.ToString();
|
||||||
return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue