Skip to content

Cannot disable a shortcut and enable another one with the same key binding. #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gsabran opened this issue May 21, 2025 · 0 comments
Open

Comments

@gsabran
Copy link

gsabran commented May 21, 2025

It is not possible to re-bind an already registered shortcut to a new one. Instead, both get called:

extension KeyboardShortcuts.Name {
    static let newFile = Self("newFile", default: .init(.n, modifiers: [.command]))
    static let newFolder = Self("newFolder", default: .init(.n, modifiers: [.command]))
}

func focusOnFiles() {
  KeyboardShortcuts.disable(.newFolder)
  KeyboardShortcuts.enable(.newFile)
}

func focusOnFolder() {
  KeyboardShortcuts.disable(.newFile)
  KeyboardShortcuts.enable(.newFolder)
}

I think this is because the KeyboardShortcuts.Name is internally converted to a Shortcut that doesn't know which Name it maps to.

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

No branches or pull requests

1 participant