Napari: Long-term stability of custom keybindings

Created on 1 Jun 2020  路  3Comments  路  Source: napari/napari

Apologies if this is a duplicate, and it's sort of a docs/bug/feature issue.

I've been using napari to make various simple GUIs for small tasks, which have a number of custom keybindings added. The issue is that if the same keybinding is added into napari at a later date, my custom keybinding stops working.

I would like to avoid pinning napari versions, so my questions are:

  • Can I make sure my keybinding overrides the core napari keybinding (not ideal).
  • Could there be a set of keybindings reserved for users to add their own?
  • Has this already been dealt with in some way, via the plugin system etc?

Thanks!

documentation question

Most helpful comment

like, a literal set of key combinations? or some sort key-combo "namespace" (like a modifier key or something)

Yeah a "namespace" would be great, i.e. napari core won't use Shift+Alt (or something like that).

I don't have any particular preferences as to how this is achieved, and I'm happy for user-added keybindings to be clunky if necessary (I should have guessed that Ctrl+S wouldn't have been free for long).

As long as I can add a keybinding, and be able to use it with each new version of napari, I'm happy.

All 3 comments

it's a great/important question.

Can I make sure my keybinding overrides the core napari keybinding (not ideal).

added keybindings are actually appended to a list. so I _think_ they will _all_ get called at the moment. This is obviously not great, and will likely be changed soon(ish).

Could there be a set of keybindings reserved for users to add their own?

like, a literal set of key combinations? or some sort key-combo "namespace" (like a modifier key or something)

Has this already been dealt with in some way, via the plugin system etc?

nope, but there's an active discussion on how we will allow plugins to offer keybindings in https://github.com/napari/napari/issues/1272 (it's a long thread... and there's no strong proposal yet for how to solve keybinding clashes)

like, a literal set of key combinations? or some sort key-combo "namespace" (like a modifier key or something)

Yeah a "namespace" would be great, i.e. napari core won't use Shift+Alt (or something like that).

I don't have any particular preferences as to how this is achieved, and I'm happy for user-added keybindings to be clunky if necessary (I should have guessed that Ctrl+S wouldn't have been free for long).

As long as I can add a keybinding, and be able to use it with each new version of napari, I'm happy.

Thanks for raising this @adamltyson - makes complete sense. We should adopt and clearly document a sane policy around this. So far it's been a little ad-hoc.

Was this page helpful?
0 / 5 - 0 ratings