Fix a crash with null textfields.
This commit is contained in:
@@ -64,6 +64,9 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public int ClosestCursorPosition(int x)
|
public int ClosestCursorPosition(int x)
|
||||||
{
|
{
|
||||||
|
if (Text == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
|
var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
|
||||||
var textSize = font.Measure(Text);
|
var textSize = font.Measure(Text);
|
||||||
|
|
||||||
@@ -141,6 +144,9 @@ namespace OpenRA.Widgets
|
|||||||
}
|
}
|
||||||
else if (!char.IsControl(c))
|
else if (!char.IsControl(c))
|
||||||
{
|
{
|
||||||
|
if (Text == null)
|
||||||
|
Text = "";
|
||||||
|
|
||||||
if (MaxLength > 0 && Text.Length >= MaxLength)
|
if (MaxLength > 0 && Text.Length >= MaxLength)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user