diff --git a/Source/Engine/UI/GUI/CanvasRootControl.cs b/Source/Engine/UI/GUI/CanvasRootControl.cs
index b5c8fd60f..c4db8776b 100644
--- a/Source/Engine/UI/GUI/CanvasRootControl.cs
+++ b/Source/Engine/UI/GUI/CanvasRootControl.cs
@@ -71,13 +71,15 @@ namespace FlaxEngine.GUI
///
public override void StartTrackingMouse(Control control, bool useMouseScreenOffset)
{
- // Not used in games (editor-only feature)
+ var parent = Parent?.Root;
+ parent?.StartTrackingMouse(control, useMouseScreenOffset);
}
///
public override void EndTrackingMouse()
{
- // Not used in games (editor-only feature)
+ var parent = Parent?.Root;
+ parent?.EndTrackingMouse();
}
///
diff --git a/Source/Engine/UI/GUI/Common/Dropdown.cs b/Source/Engine/UI/GUI/Common/Dropdown.cs
index 279f50614..02ab43db1 100644
--- a/Source/Engine/UI/GUI/Common/Dropdown.cs
+++ b/Source/Engine/UI/GUI/Common/Dropdown.cs
@@ -77,6 +77,50 @@ namespace FlaxEngine.GUI
base.OnSubmit();
}
+ ///
+ public override bool OnKeyDown(KeyboardKeys key)
+ {
+ if (key == KeyboardKeys.Escape)
+ {
+ Defocus();
+ return true;
+ }
+
+ return base.OnKeyDown(key);
+ }
+
+ ///
+ 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;
+ }
+
+ ///
+ 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;
+ }
+
///
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;