mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +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 title = this.MobileTitle ?? this.PlaceholderText;
|
||||||
var result = await KeyboardInput.Show(title, this.MobileDescription, this.Text);
|
var result = await KeyboardInput.Show(title, this.MobileDescription, this.Text);
|
||||||
if (result != null)
|
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);
|
base.Draw(time, batch, alpha, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetText(object text) {
|
public void SetText(object text, bool removeMismatching = false) {
|
||||||
if (!this.InputRule(this, text.ToString()))
|
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;
|
return;
|
||||||
this.text.Clear();
|
this.text.Clear();
|
||||||
this.text.Append(text);
|
this.text.Append(text);
|
||||||
|
|
Loading…
Reference in a new issue