开发者

eclipse-rcp : jface tableviewer cell traverse

There is a column which displaying row numbers, I want to stop u开发者_Python百科ser to traverse to cells in it using arrow keys.

eclipse-rcp : jface tableviewer cell traverse

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜