Fix sub-context menu child popup still being open when parent context menu gets focused again by the user
This commit is contained in:
@@ -196,6 +196,7 @@ namespace FlaxEditor.GUI.ContextMenu
|
|||||||
desc.HasSizingFrame = false;
|
desc.HasSizingFrame = false;
|
||||||
OnWindowCreating(ref desc);
|
OnWindowCreating(ref desc);
|
||||||
_window = Platform.CreateWindow(ref desc);
|
_window = Platform.CreateWindow(ref desc);
|
||||||
|
_window.GotFocus += OnWindowGotFocus;
|
||||||
_window.LostFocus += OnWindowLostFocus;
|
_window.LostFocus += OnWindowLostFocus;
|
||||||
|
|
||||||
// Attach to the window
|
// Attach to the window
|
||||||
@@ -353,6 +354,15 @@ namespace FlaxEditor.GUI.ContextMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnWindowGotFocus()
|
||||||
|
{
|
||||||
|
if (_childCM != null && _window && _window.IsForegroundWindow)
|
||||||
|
{
|
||||||
|
// Hide child if user clicked over parent (do it next frame to process other events before - eg. child windows focus loss)
|
||||||
|
FlaxEngine.Scripting.InvokeOnUpdate(HideChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnWindowLostFocus()
|
private void OnWindowLostFocus()
|
||||||
{
|
{
|
||||||
// Skip for parent menus (child should handle lost of focus)
|
// Skip for parent menus (child should handle lost of focus)
|
||||||
@@ -428,6 +438,21 @@ namespace FlaxEditor.GUI.ContextMenu
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override bool OnKeyDown(KeyboardKeys key)
|
||||||
|
{
|
||||||
|
if (base.OnKeyDown(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case KeyboardKeys.Escape:
|
||||||
|
Hide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnDestroy()
|
public override void OnDestroy()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -193,6 +193,8 @@ namespace FlaxEditor.Modules
|
|||||||
/// <returns>Editor window or null if cannot find any window.</returns>
|
/// <returns>Editor window or null if cannot find any window.</returns>
|
||||||
public EditorWindow FindEditor(ContentItem item)
|
public EditorWindow FindEditor(ContentItem item)
|
||||||
{
|
{
|
||||||
|
if (item == null)
|
||||||
|
return null;
|
||||||
for (int i = 0; i < Windows.Count; i++)
|
for (int i = 0; i < Windows.Count; i++)
|
||||||
{
|
{
|
||||||
var win = Windows[i];
|
var win = Windows[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user