2013-12-11 28 views
0

滾動圖表的默認方式是拖動鼠標右鍵。我需要用鼠標滾輪滾動。我還沒有找到任何API來啓用/禁用鼠標滾輪滾動。用TeeChart中的鼠標滾輪滾動圖表

我也嘗試將MouseWheelListener添加到圖表本身,但它永遠不會被調用。

是否可以在TeeChart lib中使用鼠標滾輪?

我的應用程序是使用SWT的Eclipse RCP。

+0

首先,請鏈接添加到您所使用的庫。其次,請考慮發佈[SSCCE](http://www.sscce.org),以便我們重現您正在查看的內容。 – Baz

回答

1

下面的代碼工作正常,我用的TeeChart的Java SWT在Eclipse:

所有的
Bar bar1 = new Bar(tChart1.getChart()); 
bar1.fillSampleValues(); 

tChart1.addMouseWheelListener(new MouseWheelListener() { 

    @Override 
    public void mouseScrolled(MouseEvent arg0) { 
     Axis tmpA = tChart1.getAxes().getLeft(); 
     double tmpInc = tmpA.getRange()/10; 
     if (arg0.count>0) 
      tmpA.setMinMax(tmpA.getMinimum()+tmpInc, tmpA.getMaximum()+tmpInc); 
     else 
      tmpA.setMinMax(tmpA.getMinimum()-tmpInc, tmpA.getMaximum()-tmpInc); 
    } 
}); 
+0

事實上,這是要走的路。我有完全相同的代碼,但直到我手動將焦點設置在圖表上時,它才工作。 – user3090428