slider/fader springs back to 0? Mouse button release=bang?

teqy's icon

hi everyone :)

i have an msp slider that when placed in the middle is configured to 0 db.

when i move the slider up to say +3db and let go of the mouse button i hope for the slider to spring back to 0.

So i thought if there is not a slider like this...perhaps there was a module that outputs a 0 when the right mouse button is released..that would enable me to make a little sub patch to make this happen perhaps?.

thanks for any ideas. :P

Luke Hall's icon

Look at [mousestate] the left outlet sends a 1 when the mouse is pressed and a 0 when it is released.

lh

teqy's icon

thereishopeforus@hotmail.com wrote on Tue, 28 July 2009 14:37Look at [mousestate] the left outlet sends a 1 when the mouse is pressed and a 0 when it is released.

lh

wow nice one!!

i can now simply trigger a number to set the fader back to the correct point ,on release! :P

thanks once again. :)

seejayjames's icon

you can also use [line] to set the "snap back" to however fast or slow you want.

mousestate doesn't deal with the right mouse button, but the [hi] object might (depending on your mouse), and a jit.pwindow will also report them (as "button-plus-control"). also check out [modifiers].

just some thoughts to play with

Stephen Lee's icon

Another solution is to connect the right outlet of the fader to mousefilter, and have the output of mousefilter trigger the return to 0. For example:

Max Patch
Copy patch and select New From Clipboard in Max.

The only disadvantage to this method is that adding a line object to the loop complicates things slightly, since it the line will "retrigger" itself. But you can use the line's built-in ramp value to smooth it out if the visual smoothing isn't important. On the other hand, the disadvantage of mousestate is that it will trigger the line every time you click on anything, unless you use the mouse position to determine if it is over the fader.

Roman Thilenius's icon

a custom [lcd] slider seems perfect for this.

Luke Hall's icon

You don't need to poll the mouse position, you can give your ui object a scripting name and then use [hover].

lh

teqy's icon

hi thanks fo your help.

in the end I used (hover) which lets you select areas (sliders) on the patch via scripting names..and (mousestate) for the release of the left button,using a couple of switches it works pretty well, i made a patch below with two faders to show how it works.

there is the (coll) text file you need to make called coll2.txt , place the text below inside and save it (no arrows) these are scripting names of the faders and the ports which they come out of route.
>

left, 1 left;

right, 2 right;

>

when you open the patch you have to load the coll2.txt into the (coll) module. and click the metro also.

here is the patch > hope it helps someone somewhere

Max Patch
Copy patch and select New From Clipboard in Max.