1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

fixed text fields sometimes not updating their length correctly

This commit is contained in:
Ellpeck 2019-08-11 14:18:07 +02:00
parent 2d7da2b9aa
commit 72efe55970

View file

@ -43,7 +43,7 @@ namespace MLEM.Ui.Elements {
var length = this.font.MeasureString(this.Text).X * this.TextScale; var length = this.font.MeasureString(this.Text).X * this.TextScale;
var maxWidth = this.DisplayArea.Width - this.TextOffsetX * 2; var maxWidth = this.DisplayArea.Width - this.TextOffsetX * 2;
if (length > maxWidth) { if (length > maxWidth) {
for (var i = Math.Max(0, this.textStartIndex - 1); i < this.Text.Length; i++) { for (var i = 0; i < this.Text.Length; i++) {
var substring = this.Text.ToString(i, this.Text.Length - i); var substring = this.Text.ToString(i, this.Text.Length - i);
if (this.font.MeasureString(substring).X * this.TextScale <= maxWidth) { if (this.font.MeasureString(substring).X * this.TextScale <= maxWidth) {
this.textStartIndex = i; this.textStartIndex = i;