镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

The context-menu key from ImGui, Silk.NET, GLFW and SDL ("Menu") is read as Alt, so Shift+Menu is stored as Alt+Shift and clashes with Alt bindings #222

Closed

Description

@matt-edmondson

What's wrong

CanonicalizeKey in Keybinding/Models/MusicalTypes.cs (around line 87 at 89f14b9) folds the bare name MENU to ALT:

"OPTION" or "MENU" or "LMENU" or "RMENU" or ... => "ALT",

In Win32 and WinForms, Menu does mean Alt (VK_MENU, Keys.Menu). The frameworks that #209 set out to support use the name for a different key: GLFW_KEY_MENU, Silk.NET Key.Menu, ImGuiKey.Menu and SDL SDLK_MENU are the application / context-menu key. A host that passes key.ToString() from any of these, as #209's folding invites, gets Alt for the menu key without any warning.

Failure scenario

Chord.Parse("Menu")                                   = Alt   (equals Alt: True)
bind "context.menu" to Shift+Menu  → stored chord     = Alt+Shift
bind "menu.bar" to Shift+Alt       → context.menu loses its chord (displaced)
press Shift+Menu                   → executes menu.bar

The user's context-menu binding silently merges with the Alt modifier. Binding Alt+Shift elsewhere removes it, and pressing the menu key runs the Alt command.

This is a name collision between frameworks, not a typo. The WinForms mapping is intentional and tested in Keybinding.Test/KeyAliasEquivalenceTests.cs:40, [DataRow("Menu+A", "Alt+A")], and comes from #166. Those two uses of the name can't both be served by one global alias.

Suggested fix

  • Keep LMENU/RMENU → ALT, since those are unambiguous, but stop folding the bare MENU, so it stays a key of its own. Add a comment explaining why.
  • WinForms hosts already have to map Keys.Menu from a KeyEventArgs, where e.Alt is also available. If WinForms support for the bare name matters, document it, or offer an opt-in framework alias table instead of a global fold.
  • Update the Menu+A test row to match whichever behaviour is chosen.

Acceptance criteria:

  • Chord.Parse("Shift+Menu") is not equal to Alt+Shift.
  • Binding Shift+Alt doesn't displace a Shift+Menu binding.
  • LMenu+A / RMenu+A still compare equal to Alt+A.

Activity

  1. matt-edmondson commented on Nov 5, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions