Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Omg that did the trick!

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic