diff --git a/Source/Engine/UI/GUI/Common/Dropdown.cs b/Source/Engine/UI/GUI/Common/Dropdown.cs
index a6c79ea3f..92067398d 100644
--- a/Source/Engine/UI/GUI/Common/Dropdown.cs
+++ b/Source/Engine/UI/GUI/Common/Dropdown.cs
@@ -28,15 +28,20 @@ namespace FlaxEngine.GUI
///
public ContainerControl SelectedControl = null;
+ ///
+ /// The main panel used to hold the items.
+ ///
+ public Panel MainPanel = null;
+
///
public override void OnEndContainsFocus()
{
base.OnEndContainsFocus();
// Dont lose focus when using panel. Does prevent LostFocus even from being called if clicking inside of the panel.
- if (Children[0] is Panel panel && panel.IsMouseOver && !panel.ContainsFocus)
+ if (MainPanel != null && MainPanel.IsMouseOver && !MainPanel.ContainsFocus)
{
- panel.Focus();
+ MainPanel.Focus();
return;
}
// Call event after this 'focus contains flag' propagation ends to prevent focus issues
@@ -136,6 +141,8 @@ namespace FlaxEngine.GUI
public override void OnDestroy()
{
LostFocus = null;
+ MainPanel = null;
+ SelectedControl = null;
base.OnDestroy();
}
@@ -442,6 +449,7 @@ namespace FlaxEngine.GUI
AutoFocus = true,
Parent = popup,
};
+ popup.MainPanel = panel;
var container = new VerticalPanel
{
@@ -603,8 +611,8 @@ namespace FlaxEngine.GUI
_popup.Parent = root;
_popup.Focus();
_popup.StartMouseCapture();
- if (_popup.SelectedControl != null && _popup.Children[0] is Panel panel)
- panel.ScrollViewTo(_popup.SelectedControl, true);
+ if (_popup.SelectedControl != null && _popup.MainPanel != null)
+ _popup.MainPanel.ScrollViewTo(_popup.SelectedControl, true);
OnPopupShow();
}