Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 06:53 Go to next message
Meghna Missing name is currently offline Meghna Missing nameFriend
Messages: 9
Registered: March 2011
Junior Member
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 07:45]

Report message to a moderator

Re: Amount of pixels scrolled with SWT mouseScrolled [message #657858 is a reply to message #657244] Fri, 04 March 2011 11:28 Go to previous message
Lakshmi P ShanmugamFriend
Messages: 277
Registered: July 2009
Location: India
Senior Member
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


Lakshmi P Shanmugam
Previous Topic:SWT buttons internationalization
Next Topic:Generate HTML view with SWT widget drop
Goto Forum:
  


Current Time: Mon Mar 08 17:27:09 GMT 2021

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

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

Back to the top