diff --git a/Source/Engine/UI/GUI/Tooltip.cs b/Source/Engine/UI/GUI/Tooltip.cs index 3e1fe22ac..4541124e7 100644 --- a/Source/Engine/UI/GUI/Tooltip.cs +++ b/Source/Engine/UI/GUI/Tooltip.cs @@ -73,13 +73,18 @@ namespace FlaxEngine.GUI Vector2 locationWS = target.PointToWindow(location); Vector2 locationSS = parentWin.PointToScreen(locationWS); Vector2 screenSize = Platform.VirtualDesktopSize; + Vector2 parentWinLocationSS = parentWin.PointToScreen(Vector2.Zero); + float parentWinRightSS = parentWinLocationSS.Y + parentWin.Size.Y; + float parentWinBottomSS = parentWinLocationSS.X + parentWin.Size.X; Vector2 rightBottomLocationSS = locationSS + dpiSize; - if (screenSize.Y < rightBottomLocationSS.Y) + + // Prioritize tooltip placement within parent window, fall back to virtual desktop + if (parentWinRightSS < rightBottomLocationSS.Y || screenSize.Y < rightBottomLocationSS.Y) { // Direction: up locationSS.Y -= dpiSize.Y; } - if (screenSize.X < rightBottomLocationSS.X) + if (parentWinBottomSS < rightBottomLocationSS.X || screenSize.X < rightBottomLocationSS.X) { // Direction: left locationSS.X -= dpiSize.X;