简体   繁体   中英

Scrolling TreeViewer Tree SWT

My dialog have two TreeViewer components. The vertical scroll bars have to be synchronized. I have tried with setSelection and setTopItem methods but both have no effect to other tree.

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());
    }
});

Any ideas?

The solution:

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);
        }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM