iTwin / appui

Monorepo for iTwin.js AppUi
MIT License
8 stars 2 forks source link

Allow to control when keyboard shortcuts are active. #819

Open mathieu-fournier opened 3 months ago

mathieu-fournier commented 3 months ago

Is your feature request related to a problem? Please describe.

I want to have keyboard shortcuts to do many things in my application. Some of these things require the focus to be on certain elements. Example : Delete key shortcut to delete selected elements. The problem is that keyboard shortcuts are not executed because, when elements are selected, the boolean flag 'isFocusOnHome' is false.

The thing is that most shortcuts must require some kind of context to perform an action. "Ex: having a tool active, having some element selected, etc...". The 'focus on home' check prevents shortcuts from being used. It's also counter intuitive mixed with the isActive boolean flag. So, instead of a boolean flags like isFocusOnHomeRequired and isActive, I suggest we put a predicate function so the user can control when the shortcut is active. The predicate could default to the usual isFocusOnHome check.

Describe the Solution you'd like

Letting the user decide when a keyboard shortcut is active.

Describe alternatives you've considered

See discussion : https://github.com/iTwin/appui/discussions/804

Additional context

No response