Archive for March, 2009
Appframework and accelerator keys
Today I re-researched on the topic of assigning accelerator keys to actions depending on the operating system using java appframework. The problem I have is simple. On Mac OS X the “meta” key maps to apples command key. On windows it maps to the “Alt” key. And thats is the beginning of all the trouble. Assume you want to define a “save” action. On Mac the shortcut should be “command-S”, on windows it should be “ctrl-S”. In terms of appframework (or java keystrokes) that means you need:
save.Action.accelerator=meta pressed S
if you are on Mac OS X and
save.Action.accelerator=ctrl pressed S
if you are on Windows. The simple way to to this is
save.Action.accelerator=shortcut S
and “shortcut” will map to the meta key on the mac and to the ctrl key on windows. Remember, this is appframework specific and not a real Keystroke definition. I didn’t find the documentation anywhere ( I am sure it somewhere
), but I found that while browsing the source code. It doesn’t solve all the problems related to accelerator/mnemonic/keystrokes on differen paltforms ! But, at least for me, it solved 90% of the problems, because we develope our app in english (so no other locales involved) and “ctrl” is also fine for the linux/unix/solaris platform. I you want to do more or just want to read more about the problem, there is a thread from the appframwork mailing list.