kayvanbree / contexr

Stop redundantly defining your shortcuts in your shortcut library and your context menu. Start using Contexr!
MIT License
4 stars 0 forks source link

Reuse hotkeys #24

Closed kayvanbree closed 6 years ago

kayvanbree commented 6 years ago

For now it's only possible to add one hotkey per application. The users of this library should be able to add a hotkey in the context of a component.

Use case:

Use case 2:

Current behavior

When the same hotkey is registered twice, only the last registered hotkey will work.

Expected behavior

You should be able to register a hotkey within a component. The hotkey will only fire if an HTML element with that context or a child of that element is clicked.

kayvanbree commented 6 years ago

We can track the last clicked/right-clicked context, every element that has the ctx directive. The directive will have a unique identifier using Symbol. The ContexrService keeps a list of contexts. If we give that list of context a unique object, we know which of those actions to perform. Then we call the corresponding action.

The directive should be a unique object.

kayvanbree commented 6 years ago

Now possible to use hotkeys on a per context basis in develop