Fixed ContextMenu

This commit is contained in:
Tig
2024-12-06 14:32:09 -07:00
parent 0c7d1aee8f
commit 0586c303a7
3 changed files with 4 additions and 7 deletions

View File

@@ -591,7 +591,7 @@ public partial class View // Keyboard APIs
return false;
}
private bool InvokeCommandsBoundToHotKeyOnSubviews (Key key, ref bool? handled, bool invoke = true)
internal bool InvokeCommandsBoundToHotKeyOnSubviews (Key key, ref bool? handled, bool invoke = true)
{
bool? weHandled = InvokeCommandsBoundToKey (key, KeyBindingScope.HotKey);
if (weHandled is true)

View File

@@ -109,9 +109,7 @@ public sealed class ContextMenu : IDisposable
_menuBar?.Dispose ();
_menuBar = null;
IsShow = false;
Application.KeyBindings.Remove (Key);
`
if (_container is { })
{
_container.Closing -= Container_Closing;
@@ -253,8 +251,6 @@ public sealed class ContextMenu : IDisposable
_menuBar._isContextMenuLoading = true;
_menuBar.MenuAllClosed += MenuBar_MenuAllClosed;
Application.KeyBindings.Add (Key, _menuBar, Command.Cancel);
_menuBar.BeginInit ();
_menuBar.EndInit ();
IsShow = true;

View File

@@ -250,7 +250,8 @@ internal sealed class Menu : View
protected override bool OnKeyDownNotHandled (Key keyEvent)
{
// We didn't handle the key, pass it on to host
return _host.InvokeCommandsBoundToKey (keyEvent) == true;
bool? handled = null;
return _host.InvokeCommandsBoundToHotKeyOnSubviews (keyEvent, ref handled, true ) == true;
}
protected override bool OnMouseEvent (MouseEventArgs me)