Fix mouse hovering controls under expanded dropdown list panel

This commit is contained in:
Wojtek Figat
2022-07-24 13:37:23 +02:00
parent c25305e695
commit 5fea0cd693
2 changed files with 52 additions and 3 deletions

View File

@@ -71,13 +71,15 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override void StartTrackingMouse(Control control, bool useMouseScreenOffset)
{
// Not used in games (editor-only feature)
var parent = Parent?.Root;
parent?.StartTrackingMouse(control, useMouseScreenOffset);
}
/// <inheritdoc />
public override void EndTrackingMouse()
{
// Not used in games (editor-only feature)
var parent = Parent?.Root;
parent?.EndTrackingMouse();
}
/// <inheritdoc />

View File

@@ -77,6 +77,50 @@ namespace FlaxEngine.GUI
base.OnSubmit();
}
/// <inheritdoc />
public override bool OnKeyDown(KeyboardKeys key)
{
if (key == KeyboardKeys.Escape)
{
Defocus();
return true;
}
return base.OnKeyDown(key);
}
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (base.OnMouseDown(location, button))
return true;
// Close on click outside the popup
if (!new Rectangle(Float2.Zero, Size).Contains(ref location))
{
Defocus();
return true;
}
return false;
}
/// <inheritdoc />
public override bool OnTouchDown(Float2 location, int pointerId)
{
if (base.OnTouchDown(location, pointerId))
return true;
// Close on touch outside the popup
if (!new Rectangle(Float2.Zero, Size).Contains(ref location))
{
Defocus();
return true;
}
return false;
}
/// <inheritdoc />
public override void OnDestroy()
{
@@ -468,6 +512,7 @@ namespace FlaxEngine.GUI
if (_popup != null)
{
OnPopupHide();
_popup.EndMouseCapture();
_popup.Dispose();
_popup = null;
if (_hadNavFocus)
@@ -505,6 +550,7 @@ namespace FlaxEngine.GUI
_popup.Location = locationRootSpace;
_popup.Parent = root;
_popup.Focus();
_popup.StartMouseCapture();
OnPopupShow();
}
@@ -598,7 +644,8 @@ namespace FlaxEngine.GUI
if (button == MouseButton.Left)
{
_touchDown = true;
Focus();
if (!IsPopupOpened)
Focus();
return true;
}
return false;