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’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
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.
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.
Researching a different bug, I may have found what’s causing mouseMagnify() to fail being called on Windows.
IMHO the problem lies in the fact that, when a JUCE program detects that it’s running on a Windows version that’s touch capable, it invariably registers itself as being able to receive touch events.
Specifically, if the API function RegisterTouchWindow() exists, then juce_Windowing_windows.cpp picks it up in canUseMultiTouch(), and immediately calls it on the current peer. There’s no way to opt-out of it at present moment that I know of.
The problem is, that mouseMagnify() on Windows is not triggered by touch events but by gestures (it’s only called through doGestureEvent() in juce_Windowing_windows.cpp)
And when a window is registered as being able to receive touch events because of the previously described check on RegisterTouchWindow (almost always nowadays, I guess), Windows stops sending it such gesture events:
I’m seeing this happening on a Windows machine that has no input peripherals connected to it, no mouse and no touch screen, I’m accessing it remotely. And still, the code sees it as touch capable because RegisterTouchWindow exists, and therefore JUCE peers are registered as capable of receiving multi-touch events.
This is not always desiderable, because it disables the default handling by Windows of some common gestures like long press to right-click (which is the bug I was researching for)
Yep, that’s why it fails. What I don’t know is how they can fix that, and whether they will. It’s been impossible for our plugins to use pinch to zoom gestures on Windows for years now, and it annoys users who would love to be able to zoom in and out more easily.
The simplest way would be to provide a global “switch” for turning that off (a preprocessor macro or something more elegant), or perhaps they could devise a way to toggle that per-component, although that should somehow propagate from the plug-in editor to its parent component that has an heavyweight native peer associated with it
The simplest way would be to provide a global “switch” for turning that off…
Not sure exactly why it didn’t work, but I tried commenting out the call to registerTouchWindow(), but I still did not get any gestures in the win32 message handler.
What bothers me is that I’ve never seen any response from the Juce team on this issue, in this or the related threads where this problem has been discussed.
I’d like to echo this. For developers building products that are expected to feel native on modern systems, this is increasingly a blocker rather than a feature request.
For comparison, Qt and SDL both support trackpad gesture/magnify input cross-platform, which makes JUCE’s current gap more noticeable.