Sliding from button to button


#1

Hi, does anyone know of a method where it’s possible to slide a finger across a load of toggle switches and have them activate/deactivate as the finger slides over them rather than having to press each individually?

thx


#2

I was investigating that a year ago and didn’t find a nice solution. The only thing that can work is, to let the parent Component handle that and toggle each button, when it enters the button area.

The mouseEnter of each button will not work during the mouseDrag, unfortunately.


#3

Simply use a Slider with a custom paint method. Just did exactly that yesterday.


#4

I also did something similar very recently (a slider masquerading as buttons), and found it necessary to override mouseDown to the make the setValue call take the right value in order for the “hit points” of the buttons to line up exactly. Without doing that (towards the top of the range of the slider especially) I would see undesired behaviour where a button wouldn’t register until clicking way into it’s actual area. Of course for Lee’s use case would need to override mouseDrag, but pretty sure that in Slider::mouseDown it’s calling mouseDrag which is where the setValue is happening.
edit: thinking about it, won’t this be useless for Lee’s case? He wants a bunch of toggles that can be quickly switched on/off with a swipe, the Slider version is only really useful for a “radio button” exclusive value type usage isn’t it? Perhaps if it was a completely transparent Slider over the buttons that was toggling them it could work?


#5

In my case this was the case, so slider was not an option. A slider is good for one discrete value, not for a bunch of on/off toggles…
Unless I didn’t understand the suggestion.


#6

yes agreed, don’t think this will work in my case, although the transparent slider over the top might be worth exploring