|[SOLVED] ScrolledComposite: Set scroll position? [message #1364549]
||Sun, 18 May 2014 14:52
| Alan DW
Registered: March 2012
I'm trying to resolve the following problem with SWT. I have a simple ScrolledComposite in my shell that contains a Canvas showing an image. Let us assume that the canvas (and its image) are bigger in dimensions than the scrolled composite - so the horizontal and vertical scroll bars show up.
What I would like to do now is to implement the following behaviour: When the user moves the mouse across the ScrolledComposite while holding down the middle mouse button, the scroll bars should 'follow' the mouse pointer. So basically I want to allow the user to 'pan' the view on the image with the middle mouse button.
I've got my MouseMoveListener set up and it fires nicely. However, I don't know how to change the actual scroll position.
In short, what I'm looking for is the SWT equivalent to this Swing method: JScrollPanel#setScrollPosition(int,int).
I have tried:
... but that only changes the position of the bars, it does not affect the viewport of the scrolled composite at all.
Any help would be much appreciated!
EDIT: I think I've found it. It seems to work by using scrolledComposite.getOrigin() and scrolledComposite.setOrigin(...) respectively. That's a rather... unusual name (which is why I didn't find it when searching for it) but it does make sense from a certain point of view, I guess. Correct me if I'm wrong on this one, but it does seem to work as intended.
[Updated on: Sun, 18 May 2014 14:57]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.03283 seconds