Home > Blockchain >  Eclipse SWT: Switch field using TAB instead of adding space
Eclipse SWT: Switch field using TAB instead of adding space

Time:02-18

Usually, when you press TAB in Eclipse SWT, you switch to the next field. But in certain text-fields it is adding spaces instead of switching the field. How to program this?

CodePudding user response:

This normally happens for StyledText controls.

Add a Traverse listener to the control and enable traversal for tab:

StyledText text = ....

text.addListener(SWT.Traverse, event -> {
     if (event.detail == SWT.TRAVERSE_TAB_NEXT ||
         event.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
        event.doit = true;
     }
 });
  • Related