what i am trying to archive here is to traverse within controls using the UP and DOWN arrow keys
the code goes something like this in the display object. Might seem strange but this is a requirement :-/
displayObj.addFilter(SWT.KeyDown,new Listener() {
public void handleEvent(Event event) {
Control ctrl= (Control) event.widget;
if(event.keyCode==SWT.ARROW_UP) {
ctrl.traverse(SWT.TRAVERSE_TAB_PREVIOUS);
} else if(event.keyCode==SWT.ARROW_DOWN) {
ctrl.traverse(SWT.TRAVERSE_TAB_NEXT);
}
}
});
this works fine for the texts and combo boxes. But the third field is a Button (compositeObj,SWT.CHECK) at which point this doesn’t work because a SWT.FocusOut event is generated and the focus moves to the next button ‘OK’ ‘Cancel’ instead of the combobox that sits immediately afterwards. The tab traversal correctly happens in correct order as in text, text, button , combo , button and button.
Cannot use a FocusListener because there is no way to handle the UP and DOWN arrow events separately.
Are there any other ways of doing this?. Thanks in advance for any replies.
Using TraverseListener as shown below on the buttons solved the problem.
Thanks anyway.