0

so I have

A Part with : (I will spare you the layout details, it's just to show my setup)

sc = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    drawingPane = new Composite(sc, SWT.NONE);
    drawingPane.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    sc.setContent(drawingPane);

    paintCanvas = new Canvas(drawingPane, SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND);

When I add then a MouseWheelListener to the Canvas, each Time the event occurs, the vertical Scrollbar of the ScrolledComposite is also reacting to it.

Which is kind of annoying. I tried the Solution of this Question. But the Thing is that the Canvas is the Source of the Event, which is right and I need it to be.

The question is more how can I prohibit the MouseEvent to get passed on to the ScrolledComposite? I also tried to disable the Scrollbar, but this wasn't practical as I have found no place in the Code to re-enable it afterwards. As it seems that the scrolling gets triggered after anything else(like the redraw of my canvas for example).

1 Answer 1

1

A bit more Code would be helpful. Anyway, you could try the following:

paintCanvas.addListener(SWT.MouseVerticalWheel, new Listener() {

    @Override
    public void handleEvent(Event event) {

        event.doit = false;
    }
});

But I don't think that this will work, since MouseEvents aren't TraverseEvents. I couldn't test it for myself with your code snippet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.