Multiple shortcuts for one action in GTK

What is the best way to bind multiple keyboard shortcuts to one action in GTK + 3?

I searched for the answer to this question for several days and came up with nothing. The gtk_accelerator_parse function gtk_accelerator_parse not support comma-delimited shortcuts. Placing multiple <accelerator> tags in a .ui file with the same action attribute and other key attributes also does not work.

I don’t want to write a special keystroke handler so that I have two shortcuts for one action, but is this really the only way?

+7
source share
1 answer

I found a way, but it's really terrible. Using gtk_accel_group_connect I can add additional accelerators for my own functions, which can then trigger an action based on a keystroke and any modifiers. This, however, seems like a hack, as I basically create my own acceleration and action map, rather than using GTK.

I would like to know a better way if anyone knows about this.

+1
source

All Articles