Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Amount of pixels scrolled with SWT mouseScrolled(How to get amount of pixels scrolled for FigureCanvas on mouse scroll?)
Amount of pixels scrolled with SWT mouseScrolled [message #657244] Wed, 02 March 2011 01:53 Go to next message
Eclipse UserFriend
Hi,

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()
.getVerticalRangeModel();
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 02:45] by Moderator

Re: Amount of pixels scrolled with SWT mouseScrolled [message #657858 is a reply to message #657244] Fri, 04 March 2011 06:28 Go to previous message
Eclipse UserFriend
Hi,

Another way u can try is to attach Selection listener to the scrollbar and use scrollbar.getSelection() inside the Selection listener to get the value. This way you could get the pixels after the first scroll too.
Here is an example snippet that uses the SelectionListener of the ScrollBar --> http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48. java
Previous Topic:SWT buttons internationalization
Next Topic:Generate HTML view with SWT widget drop
Goto Forum:
  


Current Time: Mon Jul 28 04:49:06 EDT 2025

Powered by FUDForum. Page generated in 0.03524 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top