aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes SWT - Mapping key actions (ie Ctrl+S = Save) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SWT - Mapping key actions (ie Ctrl+S = Save)" Watch "SWT - Mapping key actions (ie Ctrl+S = Save)" New topic
Author

SWT - Mapping key actions (ie Ctrl+S = Save)

Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
How the hell do you do that? I spent the last two hours searching google with absolutely no result!

shell.addKeyListener( new KeyAdapter ... doesn't work. It works if I add it to a text box, but how would I make a global key listener event?

This is driving me crazy, please help
Nick Kocher
Greenhorn

Joined: Nov 24, 2004
Posts: 14
Privet Ivan!
If you need Ctrl + s for your menuItem in the menu for example, you could use the following code:
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
Omg that did the trick!

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SWT - Mapping key actions (ie Ctrl+S = Save)