From 69053823104619df0197367a55e17eafce752175 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 26 Feb 2024 22:13:50 +0100 Subject: [PATCH] Fix custom context menu popup showing as child (eg. prefab diff) --- .../Editor/GUI/ContextMenu/ContextMenuBase.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs index f2feed095..511cda2e5 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs @@ -168,30 +168,30 @@ namespace FlaxEditor.GUI.ContextMenu bool isUp = false, isLeft = false; if (UseAutomaticDirectionFix) { + var parentMenu = parent as ContextMenu; if (monitorBounds.Bottom < rightBottomLocationSS.Y) { - // Direction: up isUp = true; locationSS.Y -= dpiSize.Y; - - // Offset to fix sub-menu location - if (parent is ContextMenu menu && menu._childCM != null) + if (parentMenu != null && parentMenu._childCM != null) locationSS.Y += 30.0f * dpiScale; } - if (monitorBounds.Right < rightBottomLocationSS.X || _parentCM?.Direction == ContextMenuDirection.LeftDown || _parentCM?.Direction == ContextMenuDirection.LeftUp) + if (parentMenu == null) { - // Direction: left - isLeft = true; - - if (IsSubMenu && _parentCM != null) - { - locationSS.X -= _parentCM.Width + dpiSize.X; - } - else + if (monitorBounds.Right < rightBottomLocationSS.X) { + isLeft = true; locationSS.X -= dpiSize.X; } } + else if (monitorBounds.Right < rightBottomLocationSS.X || _parentCM?.Direction == ContextMenuDirection.LeftDown || _parentCM?.Direction == ContextMenuDirection.LeftUp) + { + isLeft = true; + if (IsSubMenu && _parentCM != null) + locationSS.X -= _parentCM.Width + dpiSize.X; + else + locationSS.X -= dpiSize.X; + } } // Update direction flag