Pierre Bernard

My little hideout on the net

HHDualShortcutButton

Long time no blogging. Sorry about that.

I'll make it up to you by publishing a fresh bit of Cocoa code. HHDualShortcutButton is a NSButton subclass which may respond to 2 different keyboard shortcuts. You may know this from save confirmation sheet that pops up when you try to quit an application with dirty document. The Save button triggers its action on both Enter and command-S.

Moreover the HHDualShortcutButton will display one of its shortcuts as label when the command key is held down. This used to exist in save sheets. Now AppleWorks is the only example I can find. Currently this works only for alphanumeric shortcuts. I have not yet figured out how to represent special characters like the Return key, ...

Enjoy!
Comments