
One of the projects going on in the Second Gear labs is upgrading both Today and Check Off to run as native 64 bit applications. This involves a lot of rewiring of numbers to use the modern NSInteger/NSUInteger, removal of deprecated and removed method calls and hoping that your dependent libraries are updated as well.
With that in mind, I present SGHotKeysLib. SGHotKeysLib is a fork of Quentin D. Carnicelli’s excellent PTHotKeysLib library for registering shortcut keys on Mac OS X.
PTHotKeysLib has served us well for many years, but as I was working on upgrading my applications to run natively in 64 bit I was running into issues. The original code itself used many deprecated methods, used 32 bit integer types, etc. As I fixed those issues, my OCD started to get the best of me and I began reformatting and rewriting portions of the code using modern Objective-C practices and paradigms.
SGHotKeysLib does the following:
- Adopts Objective-C 2.0 syntax, properties and other language features (suck it dot syntax haters)
- Uses Leopard’s Text Input Sources (no patching required)
- Runs natively in 64 bit
- Supports Garbage Collection
- Removes legacy code support (no more checking for 10.1, no more Project Builder)
- Cleans up the code formatting & variable declarations
- Puts the code on GitHub for hot forking action
SGHotKeysLib includes:
- The SGHotKeysLib itself
- A sample application that demonstrates how it works.
The sample uses a custom-built version of the ShortcutRecorder framework to demonstrate setting a hot key.
SGHotKeysLib is a modernization of a piece of code many of us have been using for several years, and I’m sure it could be improved even more. If you have ideas for how to do that, please fork away. If you find the code useful, please do let me know.
