Text Widget spaces the TAB [message #898986] |
Mon, 30 July 2012 02:32 |
|
Pressing TAB to move to the next widget without having to go I'd like to put a space in text.
Why did not work?
show you my code.
thanks.
public class TextWidgetText implements IEntryPoint {
private Text text_1;
/**
* @wbp.parser.entryPoint
*/
public int createUI() {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
int style = SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
final Text text = new Text(shell, style);
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
System.out.println(e.keyCode);
if(e.stateMask == 0 && e.keyCode == SWT.TAB) {
text.insert(new Character(SWT.TAB).toString());
}
}
});
text.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
}
}
});
text_1 = new Text(shell, SWT.BORDER);
text_1.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if(e.stateMask == 0 && e.keyCode == SWT.TAB) {
text_1.insert(new Character(SWT.TAB).toString());
}
}
});
text_1.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
}
}
});
shell.setSize(404, 380);
shell.open();
// while (!shell.isDisposed()) {
// if (!display.readAndDispatch())
// display.sleep();
// }
// display.dispose();
return 0;
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02878 seconds