[brailleblaster] Re: The VerifyKeyListener

  • From: "Susan Jolly" <easjolly@xxxxxxxxxxxxx>
  • To: <brailleblaster@xxxxxxxxxxxxx>
  • Date: Sat, 11 Jun 2011 09:51:08 -0600

The StyledText widget has a lot of OS-dependent default key bindings which you can discover either from its getKeyBinding() method or by looking at the source code. You can overwrite the defaults and/or set additional bindings with the widget's setKeyBinding() method. You can listen directly for SWT.Key_Down events rather than usingVerifyKeyListener. . Here is a bit of code from the TextEditor example.


styledText.addListener(SWT.KeyDown, new Listener() {
  public void handleEvent(Event event) {
   handleKeyDown(event);
  }

Then in your handleKeyDown() method you can use event.keyCode to determine which key was pressed.

Susan

Other related posts: