From 35d6e5fd21b5afd8fb2eff071952af7e5c7fe869 Mon Sep 17 00:00:00 2001 From: Saas Date: Thu, 30 Oct 2025 20:02:15 +0100 Subject: [PATCH] fix still being able to open/ close script editor with no fields Introduces "CanOpenClose" to DropPanel. If false, will ignore the user clicking on the header (or the arrow) to open or collapse the panel --- .../CustomEditors/Dedicated/ScriptsEditor.cs | 2 ++ Source/Engine/UI/GUI/Panels/DropPanel.cs | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs index 356ae5ee4..954599347 100644 --- a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs @@ -914,9 +914,11 @@ namespace FlaxEditor.CustomEditors.Dedicated // Remove drop down arrows and containment lines if no objects in the group if (group.Children.Count == 0) { + group.Panel.Close(); group.Panel.ArrowImageOpened = null; group.Panel.ArrowImageClosed = null; group.Panel.EnableContainmentLines = false; + group.Panel.CanOpenClose = false; } // Scripts arrange bar diff --git a/Source/Engine/UI/GUI/Panels/DropPanel.cs b/Source/Engine/UI/GUI/Panels/DropPanel.cs index 0bfa799c2..de80f9fc5 100644 --- a/Source/Engine/UI/GUI/Panels/DropPanel.cs +++ b/Source/Engine/UI/GUI/Panels/DropPanel.cs @@ -104,13 +104,20 @@ namespace FlaxEngine.GUI /// /// Gets or sets a value indicating whether enable drop down icon drawing. /// - [EditorOrder(1)] + [EditorOrder(2)] public bool EnableDropDownIcon { get; set; } + /// + /// Get or sets a value indicating whether the panel can be opened or closed via the user interacting with the ui. + /// Changing the open/ closed state from code or the Properties panel will still work regardless. + /// + [EditorOrder(1)] + public bool CanOpenClose { get; set; } = true; + /// /// Gets or sets a value indicating whether to enable containment line drawing, /// - [EditorOrder(2)] + [EditorOrder(3)] public bool EnableContainmentLines { get; set; } = false; /// @@ -369,7 +376,7 @@ namespace FlaxEngine.GUI } // Header - var color = _mouseOverHeader ? HeaderColorMouseOver : HeaderColor; + var color = _mouseOverHeader && CanOpenClose ? HeaderColorMouseOver : HeaderColor; if (color.A > 0.0f) { Render2D.FillRectangle(new Rectangle(0, 0, Width, HeaderHeight), color); @@ -510,7 +517,7 @@ namespace FlaxEngine.GUI if (button == MouseButton.Left && _mouseButtonLeftDown) { _mouseButtonLeftDown = false; - if (_mouseOverHeader) + if (_mouseOverHeader && CanOpenClose) Toggle(); return true; } @@ -540,7 +547,7 @@ namespace FlaxEngine.GUI if (button == MouseButton.Left && _mouseButtonLeftDown) { _mouseButtonLeftDown = false; - if (_mouseOverHeader) + if (_mouseOverHeader && CanOpenClose) Toggle(); return true; }