Move IsDisabled checking for OnMouseDown into ButtonWidget. Remove unnecessary bool plumbing.

This commit is contained in:
Paul Chote
2011-07-04 02:22:42 +12:00
parent bbeaf2047b
commit e58e354c4b
6 changed files with 28 additions and 38 deletions

View File

@@ -24,8 +24,7 @@ namespace OpenRA.Widgets
public string Font = ChromeMetrics.Get<string>("ButtonFont");
public Func<string> GetText;
public Func<bool> IsDisabled = () => false;
public Func<MouseInput, bool> OnMouseDown = mi => false;
public Action<MouseInput> OnMouseDown = _ => {};
public Action OnClick = () => {};
public Action<KeyInput> OnKeyPress = _ => {};
@@ -88,8 +87,11 @@ namespace OpenRA.Widgets
if (mi.Event == MouseInputEvent.Down)
{
// OnMouseDown returns false if the button shouldn't be pressed
if (!OnMouseDown(mi))
if (!IsDisabled())
{
OnMouseDown(mi);
Depressed = true;
}
else
LoseFocus(mi);
}