开发者

eclipse-rcp : jface tableviewer cell traverse

开发者 https://www.devze.com 2023-03-17 14:13 出处:网络
There is a column which displaying row numbers, I want to stop u开发者_Python百科ser to traverse to cells in it using arrow keys.

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

精彩评论

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