Skip to content

Commit

Permalink
[Control] Don't close popup windows when clicking their child control…
Browse files Browse the repository at this point in the history
…s. (Fixes #72)
  • Loading branch information
jpobst committed Aug 8, 2023
1 parent 504a7bf commit a555cc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/Modern.Forms/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ public static class Application
/// <summary>
/// Hides any open popups.
/// </summary>
internal static void ClosePopups ()
internal static void ClosePopups (bool closeMenus = true, bool closePopups = true)
{
ActiveMenu?.Deactivate ();
ActivePopupWindow?.Hide ();
if (closeMenus)
ActiveMenu?.Deactivate ();

if (closePopups)
ActivePopupWindow?.Hide ();
}

/// <summary>
Expand Down
9 changes: 7 additions & 2 deletions src/Modern.Forms/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1405,10 +1405,15 @@ internal void RaiseMouseDown (MouseEventArgs e)
if (child != null)
child.RaiseMouseDown (TranslateMouseEvents (e, child));
else {
// If we're clicking on the a Control that isn't the active menu,
// If we're clicking on a Control that isn't the active menu,
// we need to close the active menu (if any)
if ((this as MenuBase)?.GetTopLevelMenu () != Application.ActiveMenu || Application.ActiveMenu is null)
Application.ClosePopups ();
Application.ClosePopups (true, false);

// If we're clicking on a Control that isn't a child of the active PopupWindow,
// we need to close the active popup (if any)
if (FindWindow () != Application.ActivePopupWindow)
Application.ClosePopups (false, true);

if (Enabled) {
Select ();
Expand Down

0 comments on commit a555cc0

Please sign in to comment.