app-model icon indicating copy to clipboard operation
app-model copied to clipboard

idea: add user-facing rendering to keybindings

Open kne42 opened this issue 3 years ago • 3 comments

in napari, we use a system to render shortcuts with special characters (e.g. the Mac Command symbol for Cmd). I’m on my phone right now so it’s hard for me to show what I mean but I hope you understand the gist

I was thinking that this sort of almost “text rendering” should belong in app-model since I imagine it has a pretty common use case

what do you think @tlambert03? I’d like to work on this but wanted to check first if people like the idea

kne42 avatar Mar 06 '23 12:03 kne42

Yeah, that makes sense! I think it could belong here too. Feel free to flesh out the proposal a bit!

tlambert03 avatar Mar 06 '23 12:03 tlambert03

it would essentially entail a method on SimpleKeyBinding and KeyBinding with a signature like this:

def to_text(self, os: OperatingSystem = None, use_symbols: bool = False) -> str:

if no os is provided, it uses the current one

if use_symbols is True, then it will sub in the unicode characters I was talking about, otherwise in the case of e.g. on Mac, Meta -> Cmd, on Win, Meta -> Win, and on Unix, Meta -> Super

kne42 avatar Mar 06 '23 13:03 kne42

ah, great, yeah i love it

tlambert03 avatar Mar 06 '23 13:03 tlambert03