How to turn on a led for the time that a button is pressed down?

lau24's icon

Hello,

I have a question about buttons. Is it possible to create a button that sends '1' for the time that you click on it with your mouse, and sends '0' when you release your mouse button? I want to turn on a led for the whole time that a button is pressed down.

Now I've done this with a toggle, but it doesn't give exactly the right effect. Since you need to click twice to turn it on and off.

Thanks a lot!

spectro's icon
Max Patch
Copy patch and select New From Clipboard in Max.

There's probably (got to be!) something simpler, and the toggle engages with mouse clicking elsewhere on the window, but it does work..

achzo's icon
Max Patch
Copy patch and select New From Clipboard in Max.
soma's icon

I had the same problem and made my own using the ubutton and an Int.

3491.GateButton.amxd
amxd
achzo's icon

@soma:

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

in M4L you can set bang transition of Button to both sides, 0 to 1 and 1 to 0

soma's icon

But the Live.button is always round, no?

achzo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

yes, but you can overlay a panel if roundness is a issue.

ch's icon

an other one using the "idle mouse" outlet of textbutton

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

`

Dan Laüt's icon

pictctrl will do the job as it comes off the shelf. And you can give it any shape you want.

This patcher increments an integer as long as pictctrl is held.

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