sindresorhus / KeyboardShortcuts

⌨️ Add user-customizable global keyboard shortcuts (hotkeys) to your macOS app in minutes
https://swiftpackageindex.com/sindresorhus/KeyboardShortcuts/documentation/keyboardshortcuts/keyboardshortcuts
MIT License
1.99k stars 185 forks source link

Update KeyboardShortcuts.swift #107

Closed iSapozhnik closed 2 years ago

iSapozhnik commented 2 years ago

I guess that was the intent - allow the outside control whether handlers are called or not.

sindresorhus commented 2 years ago

No that was not the intent (it's used internally). That's why it's not public. I'm happy to consider exposing it if you share a use-case.

iSapozhnik commented 2 years ago

The use case is pretty simple - my app supports custom user-defined shortcuts. The app has a trial period. During this period, the user can make shortcuts, but when the trial expires, I wanted to pause all the shortcuts. I'm considering the usage of dynamic shortcuts as a "Pro" feature.

sindresorhus commented 2 years ago

isPaused is not meant to be used for a long time. It only ignores events.

For example, in your case, the user would expect to be able to use those keyboard shortcuts in other apps since they're not actually used in your app, but they would not be able to because your app has them registered.

I think a .isEnabled getter/setter (which would enable/disable all shortcuts) would be a better solution. Basically, like the .enabled()/.disabled() methods, but for all the shortcuts.

For now, you could manually use .enabled()/.disabled() on your keyboard shortcuts.