Removing listeners from Scrollbar [solved] [message #686075] |
Tue, 21 June 2011 11:33  |
Eclipse User |
|
|
|
Hey,
I have a view created using SWT, including the scrollbars. I've just added listeners to the canvas, including a MouseWheelListener to zoom in and out of the image on the canvas. However, when I do this the scrollbar (when present) also reacts to the mousewheel, scrolling the image up or down in addition to zooming.
I presume that I need to use scrollbar.removeListener() in some way, but I can't figure out how. Using scrollbar.getListeners(x), where x is SWT.MouseWheel or SWT.MouseVerticalWheel also doesn't appear to give anything useful. Any advice?
A snippet of the code:
private void initScrollBars() {
ScrollBar horizontal = getHorizontalBar();
horizontal.setEnabled(false);
horizontal.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollHorizontally((ScrollBar) event.widget);
}
});
// similar code for vertical scrollbar
}
//canvas.addMouseWheelListener(new MouseWheelListener() is used in other class
Thanks! George
[Updated on: Wed, 22 June 2011 10:40] by Moderator
|
|
|
|
Re: Removing listeners from Scrollbar [message #686560 is a reply to message #686521] |
Wed, 22 June 2011 09:48  |
Eclipse User |
|
|
|
That's brilliant, thanks, it prevents the scrollwheel from scrolling the image horizontally/vertically but I can continue to use my own methods.
I was originally using a MouseWheelListener (from swt.widgets) but swapping to a generic listener was a simple change.
Cheers!
|
|
|
Powered by
FUDForum. Page generated in 0.45898 seconds