Skip to content

Commit 6916ba6

Browse files
committed
Fixes #3964. Null Reference in DoDrawBorderAndPadding
1 parent 85cf661 commit 6916ba6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Terminal.Gui/Views/Menu/Menu.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ private void AddKeyBindingsHotKey (MenuBarItem? menuBarItem)
494494

495495
private void Application_RootMouseEvent (object? sender, MouseEventArgs a)
496496
{
497-
if (a.View is { } and (MenuBar or not Menu))
497+
if (!_host._handled && !_host.HandleGrabView (a, this))
498498
{
499499
return;
500500
}

Terminal.Gui/Views/Menu/MenuBar.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1578,11 +1578,16 @@ internal bool HandleGrabView (MouseEventArgs me, View current)
15781578
&& me.Flags != MouseFlags.ReportMousePosition
15791579
&& me.Flags != 0)
15801580
{
1581-
Application.UngrabMouse ();
1581+
var parent = me.View is Adornment adornment ? adornment.Parent : me.View;
15821582

1583-
if (IsMenuOpen)
1583+
if (GetTopSuperView () == parent?.GetTopSuperView ())
15841584
{
1585-
CloseAllMenus ();
1585+
Application.UngrabMouse ();
1586+
1587+
if (IsMenuOpen)
1588+
{
1589+
CloseAllMenus ();
1590+
}
15861591
}
15871592

15881593
_handled = false;

0 commit comments

Comments
 (0)