Fix widget mouse focus
This commit is contained in:
@@ -1068,7 +1068,7 @@ namespace OpenRA
|
||||
if (selectedWidget != null)
|
||||
return true;
|
||||
|
||||
return rootWidget.GetEventBounds().Contains(mousePos.X, mousePos.Y)
|
||||
return rootWidget.HitTest(mousePos)
|
||||
|| buttons.Any(a => a.First.Contains(mousePos.ToPoint()));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Container:
|
||||
ClickThrough:true
|
||||
Children:
|
||||
Background@MAINMENU_BG:
|
||||
Id:MAINMENU_BG
|
||||
@@ -248,19 +249,6 @@ Container:
|
||||
Delegate:IngameChromeDelegate
|
||||
Visible:false
|
||||
Children:
|
||||
PerfGraph@PERFGRAPH:
|
||||
Id:PERFGRAPH
|
||||
X:10
|
||||
Y:WINDOW_BOTTOM - 250
|
||||
Width:200
|
||||
Height:200
|
||||
Label@PERFTEXT:
|
||||
Id:PERFTEXT
|
||||
Bold: false
|
||||
X:10
|
||||
Y:WINDOW_BOTTOM - 40
|
||||
Width:200
|
||||
Height:100
|
||||
SpecialPowerBin@INGAME_POWERS_BIN:
|
||||
Id:INGAME_POWERS_BIN
|
||||
X:0
|
||||
@@ -309,6 +297,32 @@ Container:
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Quit
|
||||
Background@PERF_BG:
|
||||
ClickThrough:true
|
||||
Id:PERF_BG
|
||||
Background:dialog4
|
||||
Delegate:PerfDebugDelegate
|
||||
X:10
|
||||
Y:WINDOW_BOTTOM - 250
|
||||
Width: 210
|
||||
Height: 250
|
||||
Visible: true
|
||||
Children:
|
||||
PerfGraph@GRAPH:
|
||||
ClickThrough:true
|
||||
Id:GRAPH
|
||||
X:5
|
||||
Y:5
|
||||
Width:200
|
||||
Height:200
|
||||
Label@TEXT:
|
||||
ClickThrough:true
|
||||
Id:TEXT
|
||||
Bold: false
|
||||
X:20
|
||||
Y:210
|
||||
Width:200
|
||||
Height:100
|
||||
Background@MUSIC_BG:
|
||||
Id:MUSIC_BG
|
||||
Delegate:MusicPlayerDelegate
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Container:
|
||||
ClickThrough:true
|
||||
Children:
|
||||
Background@MAINMENU_BG:
|
||||
Id:MAINMENU_BG
|
||||
@@ -297,6 +298,7 @@ Container:
|
||||
Height:25
|
||||
Text:Quit
|
||||
Background@PERF_BG:
|
||||
ClickThrough:true
|
||||
Id:PERF_BG
|
||||
Background:dialog4
|
||||
Delegate:PerfDebugDelegate
|
||||
@@ -307,12 +309,14 @@ Container:
|
||||
Visible: true
|
||||
Children:
|
||||
PerfGraph@GRAPH:
|
||||
ClickThrough:true
|
||||
Id:GRAPH
|
||||
X:5
|
||||
Y:5
|
||||
Width:200
|
||||
Height:200
|
||||
Label@TEXT:
|
||||
ClickThrough:true
|
||||
Id:TEXT
|
||||
Bold: false
|
||||
X:20
|
||||
|
||||
Reference in New Issue
Block a user