Fix widget mouse focus

This commit is contained in:
Paul Chote
2010-04-11 16:49:06 +12:00
parent f2e95d04de
commit a75d173371
4 changed files with 41 additions and 14 deletions

View File

@@ -36,6 +36,7 @@ namespace OpenRA.Widgets
public readonly string Width = "0";
public readonly string Height = "0";
public readonly string Delegate = null;
public readonly bool ClickThrough = false;
public bool Visible = true;
public readonly List<Widget> Children = new List<Widget>();
@@ -87,6 +88,14 @@ namespace OpenRA.Widgets
Game.CreateObject<IWidgetDelegate>(d);
}
public bool HitTest(int2 xy)
{
if (!IsVisible()) return false;
if (Bounds.Contains(xy.ToPoint()) && !ClickThrough) return true;
return Children.Any(c => c.HitTest(xy));
}
public Rectangle GetEventBounds()
{
return Children