Getting void mouseMagnify() to work

On my Windows 10 machine, I’m running the following line of code:

 void mouseMagnify(const MouseEvent& mouse, float scale) override { DBG(scale); }

But it doesn’t respond at all when I test it.

I’ve tried it in a variety of Components and projects. Is there something I’m missing?

Can you override any other mouse functions on your component?

What happens when you do:

// Click anywhere in your component to test
void mouseDown (const MouseEvent& event) override { DBG("TEST"); } 

mouseMagnify is called when a pinch-to-zoom mouse-gesture is used. How are you emitting that “signal”?

Other mouse functions such as mouseDown are working as I would expect them to.

To test mouseMagnify I’m holding the mouse over the given component and then pinch-zooming on my trackpad, and nothing happens. I’ve also tested to make sure that the component has keyboard focus, and it does.

Obviously the message is being lost somewhere upstream, but I don’t know where to look.

I’m getting the same result as you. I can pinch zoom in the Windows10 Photos app with my track pad, but nothing happens in the JUCE component.

My Laptop is a 2018 Dell Vostro.

I’ve just run into the same problem on macOS 10.13.6

All other mouse methods are being fired, but mouseMagnify never gets called when performing a pinch gesture over the component I have overridden it for.

Can reproduce by starting a new Plugin from Projucer, adding

    void mouseMagnify(const juce::MouseEvent &event, float scaleFactor) override
        DBG("mouseMagnify called");

to PluginEditor.h and running the standalone: no DBG messages are output.

Is there something I missed somewhere?

You’ll have to dig into it unfortunately. The flow that leads to that function goes through the generic handleMagnifyGesture function, and prior to that, on macOS it goes through magnify which is supposed to be triggered by magnifyWithEvent.

1 Like

Well, this is embarrassing: I put a breakpoint in handleMagnifyGesture and followed it through to my component’s mouseMagnify method.

Now everything is working as expected!

Christ knows what happened before, perhaps I need more coffee! :wink:

I haven’t had such luck as @jrlanglois.

I put a breakpoint at line 97 of juce_ComponentPeer.cpp:

void ComponentPeer::handleMagnifyGesture (MouseInputSource::InputSourceType type, Point<float> pos, int64 time, float scaleFactor, int touchIndex)
    if (auto* mouse = Desktop::getInstance().mouseSources->getOrCreateMouseInputSource (type, touchIndex))
        MouseInputSource (*mouse).handleMagnifyGesture (*this, pos, time, scaleFactor);

But it never breaks when I pinch-zoom on my trackpad.

Then I followed the call hierarchy all the way back to line 3395 in juce_win32_Windowing.cpp:

static LRESULT CALLBACK windowProc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
        // Ensure that non-client areas are scaled for per-monitor DPI awareness v1 - can't
        // do this in peerWindowProc as we have no window at this point
        if (message == WM_NCCREATE && enableNonClientDPIScaling != nullptr)
            enableNonClientDPIScaling (h);

        if (auto* peer = getOwnerOfWindow (h))
            jassert (isValidPeer (peer));
            return peer->peerWindowProc (h, message, wParam, lParam);

        return DefWindowProcW (h, message, wParam, lParam);

I put a breakpoint here, with condition “message == 0x119”. (windowProc() breaks all the time, but as far as I can tell, “message == 0x119” is the condition that should lead to handleMagnifyGesture () being called). But this breakpoint is also never reached. Visual Studio can’t find any higher results than windowProc() on the call hierarchy, so I’m stuck.

I’m still dead in the water because of this problem. Can anyone help? It seems possible that the problem is not with JUCE but on some other level on my laptop, but I really have no idea where to begin searching.

This seems to be a JUCE issue - my mouseMagnify handler works flawlessly on a Macbook, but doesn’t get called when doing a zoom gesture on a Windows Laptop’s trackpad. Other applications on that laptop do allow me to zoom via gesture, but JUCE just treats it like scrolling.