Mousewheel and SliderPropertyComponent issue

Anyone have any workarounds for this frustrating behaviour. My slider properties increment/decrement when trying to scroll up and down through a set of properties in a property panel (if the mouse is currently over the slider).

Oct-19-2022 19-03-35

I know I can probably build my own slider property class and disable the mouse wheel event, but I’m hoping there is a way to simply disable this behaviour. I read a post from many years ago about adding a Component::setInterceptsMouseWheel() but it doesn’t seem to have come to fruition. Any ideas?

In the interest of closure, here’s what I did in the end. Create my own SliderProperty class, with its own sublassed Slider, that overrides the mouse wheel move event.

    struct NonMouseWheelSlider : public Slider
    {
        void mouseWheelMove (const MouseEvent &event, const MouseWheelDetails &wheel) override{}
    };

And to make sure that the mouse wheel move events get passed to the property component - add the property component as a mouse listener to the slider object. :+1:

1 Like

Similar issues have surfaced several times in the past. To solve it cleanly, I think it would make sense to add to Component the possibility of ignoring just mouse wheel events, while still receiving the other events.
If it were possible to do that, the Sliders for properties in this use case, could specify that they ignore those events, so that they get passed to the underlying viewport for scrolling.

For example, such a feature could be implemented as a setInterceptsMouseWheel() method, that does the same as setInterceptsMouseClicks(), but just for mouse wheel events.

1 Like

Agreed, this seems be the most elegant solution.

I totally agree, but I would love something more comprehensive that allows to decide dynamically what kind of mouse events are passed into that Component and which are ignored and instead handled by the parent.

For example, I’d love to have a callback to decide that the wheel is only handled when a hotkey is pressed, or that a Component will only handle left clicks and ignore right clicks.

2 Likes

mousewheel behaviour is the most broken aspect about juce::Slider entirely. not just when you try to turn it off completely in the context of a scrolling component, but also just that you can’t adjust the size of each step, which is far too large, and most importantly you can’t enable sensitive drag on ctrl+mousewheel or shift+mousewheel, which makes endless amounts of free- as well as commercial plugins end up without this feature even though it was de facto standard in every good vst plugin like 10 years ago or so. juce should put some effort into fixing this. even considering that i moved away from slider completely it would still at least help all the ones who want to stick close to the framework and in the end help me as a user not being frustrated about bad mousewheel interpretation in almost every plugin i test

Your point sounds fair, it would allow for a far more fine customization.

If you were thinking about a virtual function, returning whether the Component is interested in a certain kind of event or not, I’ll add that a lambda could even be a better choice because that wouldn’t require subclassing all the existing widgets just to have this customization.

1 Like

It seems I overlooked the Slider::setMouseWheelEnabled() method.

1 Like

That’s certainly an improvement, but just by coincidence these days I’m facing an issue where I’d like there were a way to discern between the two behaviours via a modifier.

For example, picture a scrollable long list of horizontal faders.
With a traditional, unmodified input on the mouse wheel, I’d like to scroll the list, as one would expected.

But it would also be nice if I could act on one of such faders, by hovering on it and SHIFT+wheeling on it. If I recall correctly, SHIFT+wheel is used in several places to perform a horizontal scrolling, which is particularly fit in this case

Timely conversation - I have a scenario where it would be ideal to have a slider respond to the mouse wheel ONLY (that is, to ignore mouse clicks and let those pass through). One might think that was achievable via:

	mySlider.setInterceptsMouseClicks(false, true);
	mySlider.setScrollWheelEnabled(true);

but alas it appears setInterceptsMouseClicks() should really be named setInterceptsMouseEvents()
as it prevents ALL mouse events from getting through (not just clicks), and I don’t see an easy way around that.

1 Like