I was helping a colleague today with a key binding issue that I think is fairly common. To illustrate the problem, let’s look at what happens when you press CMD+N in the RCP mail sample:
What!? New Project Wizard? That’s not what I wanted! In this case, I actually wanted a ‘New Message’ to pop up instead of that new wizard. I don’t want any of my end-users ever seeing this dialog! What’s the problem here? Well, in simple terms, Eclipse is using its own default key configuration scheme if you don’t set one. So by default, you may get strange results like above or even conflicts with existing key bindings.
What’s the solution?
Well, there are a few ways to go about this but I think the simplest one for most people is to simply create your own key configuration scheme and instruct Eclipse to use it. To do this, you first need to create your own scheme:
<extension point="org.eclipse.ui.bindings"> <scheme id="mail.scheme" name="My Mail Scheme"> </scheme> </extension>
After that, make sure your bindings are instructed to use this scheme:
<extension point="org.eclipse.ui.bindings"> <key commandId="mail.open" schemeId="mail.scheme" sequence="M1+N"> </key> <key commandId="mail.openMessage" schemeId="mail.scheme" sequence="M1+3"> </key> <key commandId="org.eclipse.ui.file.exit" schemeId="mail.scheme" sequence="M1+X"> </key> </extension>
Finally, you need to create a plugin_customization.ini if you don’t have one already for your application and put this in there:
That’s it. Once you do that, you should have key binding bliss:
Thanks for listening and let me know if this helps. Here is the sample project for reference.