Skip to content

Fixes #5757-MenuItem.Key with BindKeyToApplication does not fire Action while PopoverMenu is closed - #5758

Merged
BDisp merged 2 commits into
tui-cs:developfrom
BDisp:fix/5757-menuitemkey-with-bindkeytoapplication-does-not-fire-action-while-popovermenu-is-closed
Oct 30, 2026
Merged

BDisp merged 2 commits into
tui-cs:developfrom
BDisp:fix/5757-menuitemkey-with-bindkeytoapplication-does-not-fire-action-while-popovermenu-is-closed

Conversation

@BDisp

@BDisp BDisp commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes

Summary

  • Allow application-scoped HotKey (KeyBinding.Target) in DefaultHotKeyHandler
    even when the view is not visible (closed PopoverMenu).
  • Re-register BindKeyToApplication shortcuts once App is available
    (Shortcut.OnSuperViewChanged, MenuBarItem.EndInit).
  • Unit test: MenuItem_BindKeyToApplication_Fires_Action_When_Popover_Closed.

Docs (follow-up or same PR)

  • Clarify BindKeyToApplication in shortcut.md / menus.md MenuItem samples.
  • Update command.md DefaultHotKeyHandler steps for visibility + app scope.

Test plan

  • MenuItem_BindKeyToApplication_Fires_Action_When_Popover_Closed
  • Existing KeyDown_App_Scope_* / MenuItem_HotKey_Fires_Action_When_Open

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

DefaultHotKeyHandler refused HotKey when CanBeVisible was false, so app-scoped MenuItem.Key only worked with that MenuBarItem's menu open.
Skip the visibility gate for application-scoped bindings, re-register shortcuts once App is available (EndInit / SuperViewChanged), and cover with a unit test.
@BDisp
BDisp requested a review from tig as a code owner October 29, 2026 19:10

@tig tig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@BDisp
BDisp merged commit 84ea67c into tui-cs:develop Oct 30, 2026
14 checks passed
@BDisp
BDisp deleted the fix/5757-menuitemkey-with-bindkeytoapplication-does-not-fire-action-while-popovermenu-is-closed branch October 30, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MenuItem.Key with BindKeyToApplication does not fire Action while PopoverMenu is closed

2 participants