|Amount of pixels scrolled with SWT mouseScrolled [message #657244]
||Wed, 02 March 2011 06:53
| Meghna Missing name
Registered: March 2011
I have added swt MouseWheelListener to FigureCanvas object, sequenceDiagramCanvas & overrided the mouseScrolled(MouseEvent e) method. The swt MouseEvent gives information about the no. of times the mouse is scrolled but not the number of pixels scrolled per scroll. In order to find out the no. of pixels scrolled(i.e. scrollOffset), I tried the following code:-
RangeModel model = sequenceDiagramCanvas.getViewport()
int vBarOffset = Math.max(0, -model.getMinimum());
scrollOffset = sequenceDiagramCanvas.getVerticalBar()
.getSelection() - vBarOffset;
But the scrollOffset is returned zero for the first scroll, as sequenceDiagramCanvas.getVerticalBar().getSelection() is zero for the first scroll. From the subsequent scrolls, the scrollOffset value is correct.
Any pointers to get the no. of pixels scrolled for the first scroll or is there any other way?
[Updated on: Wed, 02 March 2011 07:45]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01478 seconds