What is the best way to bind multiple keyboard shortcuts to one action in GTK+ 3?
I have been searching for an answer to this for a few days and have come up with naught. The function gtk_accelerator_parse
does not support comma-deliminated shortcuts. Putting multiple <accelerator>
tags in a .ui
file with the same action
attribute and different key
attributes also does not work.
I do not want to have to write a custom key press handler just so I can have two shortcuts for one action, but is that really the only way?
Since GTK version 3.12 (released on 2014-03-25) there is a new method called gtk_application_set_accels_for_action()
that should help.
I have found a way, but it is truly terrible. Using gtk_accel_group_connect
I can add additional accelerators for my own functions which can then trigger the action desired based off the key pressed and any modifiers. This however feels like a hack as I am basically creating my own accelerator-to-action map rather than using GTK's.
I would like to know a better way, if anyone knows of one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With