我的对话框有两个TreeViewer
个组件。垂直滚动条必须同步。
我尝试使用setSelection
和setTopItem
方法,但两者都对其他树没有影响。
xViewerLeft = createXViewer(leftComposite, this);
xViewerRight = createXViewer(rightComposite, this);
xViewerLeft.getTree().getVerticalBar().addListener(SWT.Selection, new Listener() {
@Override public void handleEvent(Event arg0) {
//xViewerRight.getTree().setSelection(xViewerLeft.getTree().getSelection());
//xViewerRight.getTree().setTopItem(xViewerLeft.getTree().getTopItem());
}
});
有什么想法吗?
答案 0 :(得分:-2)
解决方案:
vBar1.addListener(SWT.Selection, new Listener() {
@Override public void handleEvent(Event arg0) {
double y = vBar1.getSelection()*xViewerRight.getTree().view.bounds().height/100;
NSPoint nsPoint = new NSPoint();
nsPoint.x = 0;
nsPoint.y = y;
xViewerRight.getTree().view.scrollPoint(nsPoint);
}
});