keyboard shortcuts
I am writing a bunch of USB-HID keyboard shortcuts for some extensions I am writing. Usually one shortcut per def. Since my decoding of HID is integrally tied to the extension, I would like to simplify all my shortcuts coming from one device to one def. As of now if I have 100 button commands I have to 1) register 100 shortcuts, 2) create 100 defs, 3) do corresponding stuff in my extension. I would prefer to call one def that passes the actual keyboard string to my extension, thereby simplifying my user accelerators to just registration. How do I get the string within my keyboard shortcuts python file? thanks, Matthew Dougherty National Center for Macromolecular Imaging Baylor College of Medicine
Hi Matt, I don't understand your question. Is the idea that you want to register a single keyboard shortcut handler that handles many different shortcuts and takes the two-letter shortcut characters as an argument? You would still need to register that function for every set of shortcut keys it handles. You could do something like from Accelerators import add_accelerator as add add('pq', 'Here is a description of what this shortcut does', lambda: myHandler('pq')) The "lambda" business is Python code that creates a function, in this case taking no arguments. And in this example it calls the funtion myHandler with argument "pq". Tom On Dec 27, 2013, at 4:56 PM, "Dougherty, Matthew T" wrote:
I am writing a bunch of USB-HID keyboard shortcuts for some extensions I am writing.
Usually one shortcut per def. Since my decoding of HID is integrally tied to the extension, I would like to simplify all my shortcuts coming from one device to one def.
As of now if I have 100 button commands I have to 1) register 100 shortcuts, 2) create 100 defs, 3) do corresponding stuff in my extension. I would prefer to call one def that passes the actual keyboard string to my extension, thereby simplifying my user accelerators to just registration.
How do I get the string within my keyboard shortcuts python file?
thanks,
Matthew Dougherty National Center for Macromolecular Imaging Baylor College of Medicine _______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
participants (2)
-
Dougherty, Matthew T
-
Tom Goddard