From cee6aad0ef87b6644a6125b4b6fb2331d0f92ebf Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 7 Mar 2024 22:13:56 +0100 Subject: [PATCH] Add automatic last dangling separator removal in context menu --- Source/Editor/GUI/ContextMenu/ContextMenu.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenu.cs b/Source/Editor/GUI/ContextMenu/ContextMenu.cs index a0a9b1cb8..6909d350d 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenu.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenu.cs @@ -359,6 +359,17 @@ namespace FlaxEditor.GUI.ContextMenu ButtonClicked?.Invoke(button); } + /// + public override void Show(Control parent, Float2 location) + { + // Remove last separator to make context menu look better + int lastIndex = Children.Count - 1; + if (lastIndex >= 0 && Children[lastIndex] is ContextMenuSeparator separator) + separator.Dispose(); + + base.Show(parent, location); + } + /// public override bool ContainsPoint(ref Float2 location, bool precise) {