mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 01:39:23 +01:00
made the text field remove mismatching characters on mobile input
This commit is contained in:
parent
334dea8b39
commit
f65cd58a80
1 changed files with 10 additions and 3 deletions
|
@ -56,7 +56,7 @@ namespace MLEM.Ui.Elements {
|
|||
var title = this.MobileTitle ?? this.PlaceholderText;
|
||||
var result = await KeyboardInput.Show(title, this.MobileDescription, this.Text);
|
||||
if (result != null)
|
||||
this.SetText(result.Replace('\n', ' '));
|
||||
this.SetText(result.Replace('\n', ' '), true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -112,8 +112,15 @@ namespace MLEM.Ui.Elements {
|
|||
base.Draw(time, batch, alpha, offset);
|
||||
}
|
||||
|
||||
public void SetText(object text) {
|
||||
if (!this.InputRule(this, text.ToString()))
|
||||
public void SetText(object text, bool removeMismatching = false) {
|
||||
if (removeMismatching) {
|
||||
var result = new StringBuilder();
|
||||
foreach (var c in text.ToString()) {
|
||||
if (this.InputRule(this, c.ToString()))
|
||||
result.Append(c);
|
||||
}
|
||||
text = result.ToString();
|
||||
} else if (!this.InputRule(this, text.ToString()))
|
||||
return;
|
||||
this.text.Clear();
|
||||
this.text.Append(text);
|
||||
|
|
Loading…
Reference in a new issue