There is a column which displaying row numbers, I want to stop u开发者_Python百科ser to traverse to cells in it using arrow keys.
In above picture, the cell with text "testDO3" is currently focused and highlighted, the row number column is used to select the whole row, so I want to make it not travsersable.here is my own solution:
tv.getTable().addTraverseListener(new TraverseListener(){
public void keyTraversed(TraverseEvent e) {
ViewerCell cell = focusCellManager.getFocusCell();
if(e.keyCode == SWT.ARROW_LEFT && cell.getColumnIndex() == 2){
e.detail = SWT.TRAVERSE_NONE;
e.doit = true;
}
}
});
Assuming you're using JFace cell navigation, then sub-class CellNavigationStrategy
and use in constructor of TableViewerFocusCellManager
.
精彩评论