Cache main panel, cleanup cached variables.
This commit is contained in:
@@ -28,15 +28,20 @@ namespace FlaxEngine.GUI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ContainerControl SelectedControl = null;
|
public ContainerControl SelectedControl = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The main panel used to hold the items.
|
||||||
|
/// </summary>
|
||||||
|
public Panel MainPanel = null;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnEndContainsFocus()
|
public override void OnEndContainsFocus()
|
||||||
{
|
{
|
||||||
base.OnEndContainsFocus();
|
base.OnEndContainsFocus();
|
||||||
|
|
||||||
// Dont lose focus when using panel. Does prevent LostFocus even from being called if clicking inside of the panel.
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
// Call event after this 'focus contains flag' propagation ends to prevent focus issues
|
// Call event after this 'focus contains flag' propagation ends to prevent focus issues
|
||||||
@@ -136,6 +141,8 @@ namespace FlaxEngine.GUI
|
|||||||
public override void OnDestroy()
|
public override void OnDestroy()
|
||||||
{
|
{
|
||||||
LostFocus = null;
|
LostFocus = null;
|
||||||
|
MainPanel = null;
|
||||||
|
SelectedControl = null;
|
||||||
|
|
||||||
base.OnDestroy();
|
base.OnDestroy();
|
||||||
}
|
}
|
||||||
@@ -442,6 +449,7 @@ namespace FlaxEngine.GUI
|
|||||||
AutoFocus = true,
|
AutoFocus = true,
|
||||||
Parent = popup,
|
Parent = popup,
|
||||||
};
|
};
|
||||||
|
popup.MainPanel = panel;
|
||||||
|
|
||||||
var container = new VerticalPanel
|
var container = new VerticalPanel
|
||||||
{
|
{
|
||||||
@@ -603,8 +611,8 @@ namespace FlaxEngine.GUI
|
|||||||
_popup.Parent = root;
|
_popup.Parent = root;
|
||||||
_popup.Focus();
|
_popup.Focus();
|
||||||
_popup.StartMouseCapture();
|
_popup.StartMouseCapture();
|
||||||
if (_popup.SelectedControl != null && _popup.Children[0] is Panel panel)
|
if (_popup.SelectedControl != null && _popup.MainPanel != null)
|
||||||
panel.ScrollViewTo(_popup.SelectedControl, true);
|
_popup.MainPanel.ScrollViewTo(_popup.SelectedControl, true);
|
||||||
OnPopupShow();
|
OnPopupShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user