From 3d7d7ff2a56da289d774b70a7e637fbda9a707ce Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 20 Oct 2015 17:57:19 +0100 Subject: [PATCH] Allow chrome yaml to define disabled text fields. --- OpenRA.Mods.Common/Widgets/TextFieldWidget.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs b/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs index f48c3d7ed5..f18d6872bd 100644 --- a/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs +++ b/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs @@ -28,6 +28,8 @@ namespace OpenRA.Mods.Common.Widgets public int LeftMargin = 5; public int RightMargin = 5; + public bool Disabled = false; + public Func OnEnterKey = () => false; public Func OnTabKey = () => false; public Func OnEscKey = () => false; @@ -36,14 +38,18 @@ namespace OpenRA.Mods.Common.Widgets public Action OnTextEdited = () => { }; public int CursorPosition { get; set; } - public Func IsDisabled = () => false; + public Func IsDisabled; public Func IsValid = () => true; public string Font = ChromeMetrics.Get("TextfieldFont"); public Color TextColor = ChromeMetrics.Get("TextfieldColor"); public Color TextColorDisabled = ChromeMetrics.Get("TextfieldColorDisabled"); public Color TextColorInvalid = ChromeMetrics.Get("TextfieldColorInvalid"); - public TextFieldWidget() { } + public TextFieldWidget() + { + IsDisabled = () => Disabled; + } + protected TextFieldWidget(TextFieldWidget widget) : base(widget) { @@ -54,6 +60,7 @@ namespace OpenRA.Mods.Common.Widgets TextColorDisabled = widget.TextColorDisabled; TextColorInvalid = widget.TextColorInvalid; VisualHeight = widget.VisualHeight; + IsDisabled = widget.IsDisabled; } public override bool YieldKeyboardFocus()