mouseWheelMove receiving two similar signals

Hi everyone,

I've just started using JUCE a week ago and I am already delighted of all the functionnalities already included in it : developping an application is a real pleasure - so thanks Jules and the Juce team for that ;)

I am trying to build some kind of zoom function : if the user uses the mouse wheel on a component, it's zooming in or out depending on the direction. However, the listener MouseListener::mouseWheelMove seems to receive the signal (well the broadcast, sorry I was using Qt before) two times. Those are similar signals, with the same deltaY property.

My code is quite basic :

The Constructor : 

    graphique() : zoomFactor(1)
        // In your constructor, you should add any child components, and
        // initialise any special settings that your component needs.
        setSize(400, 200);
        addMouseListener(this, false);

The listener :

    virtual void mouseWheelMove(const MouseEvent &     event, const MouseWheelDetails &     wheel) {
            if (wheel.deltaY <= 0) {
                zoomFactor *= 2;
            else {
                if (zoomFactor > 1) 
                    zoomFactor /= 2;                

Is it "normal" ? What can I do to zoom only on the first signal ? I've been thinking of using the event timestamp but it may not be a good idea depending on how mice behave...

I tried with two mice by the way, with normal "stop-scroll", not infinity scroll (sorry no idea how it's supposed to be called).

Thanks a lot by advance,


If you add a component as a mouse-listener to itself, then it'll receive both the callbacks it would have got anyway, and then be called again as a listener, so yes, you'd get two calls. Probably no need to have the addListener call?

Oh my god,

Stupid me :) Thank you very much, it's very clear now.