Hi, to register keyboard shortcuts from a scripted module i have been putting the code in the setup method of my widget class, however there is a need to run each module to register its shortcuts, where should shortcut registration be placed in a module so it can run as soon as slicer starts?
I tried setting it as a separate method in widget class then call it but then i get "Failed to obtain reference to ‘qSlicerMainWindow’ " error
Thanks a lot.
Indeed slicerrc needs to be edited which is not ideal for module sharing.
startupComplete() signal is exactly what i was looking for. Thanks a lot for your help.
Note to interested people: i had to put in the init method of the main module class to be run at slicer’s startup
If there is a risk of shortcuts conflicting between modules, and you only want to use specific shortcuts in your module, you could have a look at this example (search for “shortcut” in the code). It installs shortcuts when you enter the module, but uninstalls them when you switch to a different module.
Thanks for the precision, that will definitely come in handy,
i don’t see how enter and exit methods (lines 317 and 375) get called? do slicer recognize their names and runs them automatically like the setup method?