On Thu, 27 Jun 2013 02:50:02 GMT, Joel wrote:
Eg. Control + S to save (or what ever)
I've got a program with a notes part of it and I want to be able to just hit Control + S to save, instead of using the mouse each time.
Thanks.
To setup keyboard shortcuts you'll need to create an accelGroup and add it to the window.
AccelGroup accelGroup = new AccelGroup();
window.addAccelGroup(accelGroup);
And when creating the MenuItems you can pass in the accelGroup and set the accelKey:
new MenuItem(&onSave, "_Save", "file.save", true, accelGroup, 's');
Now onSave will be called when the menu item is clicked and when the Window receives Crtl+S.