toggle puzzle...

n871's icon

hello,

Can someone help me to find the solution to my problem?

I need 4 toggle objects to behave like a groupradio or tab object. In other words: only 1 toggle can be selected at any time. If you press a selected toggle (position 1) again, nothing should happen until one of the other 3 is pressed.

I can't use radiogroup because of midicontrol reasons, it has to work this way, so far no luck...
If anyone can help, please do!

thank you, N871

Wetterberg's icon

what are they connected to? There might be a simpler way of doing it, that doesn't involve four toggles...

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

Hello Wetterberg,

thank you for your kind reply and patch! The toggles are connected to many, many things.
May I ask how difficult it would be to add 1 feature to your patch: "if one hits the toggle again that is selected, nothing should happen".

possible?

n871's icon

I can't work with the ignore click attribute because the toggles also have to be controlled by midi messages (next to the use of the mouse). The obvious way to go would be to use radiogroup instead but can I send 4 hardware buttons each with their own ctrlin number to a single radiogroup object?

n871's icon

Actually, although the use of toggles involves more connections, it is working great in my patch, I guess it's not that big of a deal CPU-wise.
if I can find the solution to this last problem involving hitting the selected toggle again I'll be just fine :)

Wetterberg's icon

again, you're basically saying you want toggles that don't toggle... ;)

n871's icon

Yes that's true :) I have 4 hardware buttons, let's say Ctlin 1, Ctlin 2, Ctlin 3 and Ctlin 4. They need to work as a radiogroup.
that's it.

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

well... I think I might have found the solution in this crazy looking patch...

Wetterberg's icon

eww... I will have no part in this!

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

I think this one is better... ...would have been cool to be able to arrange the radiogroup as 2x2 instead of 4 in a row.

Wetterberg's icon

yes, that was part of my first patch as well, if you look again? ;)

Christopher Dobrian's icon

Long, long time ago there was this document called Macintosh Human Interface Guidelines, which was written as the result of lots of research and thought on the topic, which specified that one appearance (radio buttons) be used for allowing a single (exclusive) choice among options and that a different appearance (checkboxes) be used for allowing the user to choose multiple options. That's why the radiogroup object is designed the way it is. Of course, you're not obliged to follow that convention, but it's perhaps worth knowing that it exists, since it has been adopted by several other operating systems.

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

But if you want to have a group of toggles that behaves as a radiogroup, why not just make a (hidden) subpatch that captures and manages the toggle states and sends out the desired info? Here's an example. It has four inlets (for your four toggles) and five outlets (outlets 1-4 to manage the toggles' appearance, and outlet 0 to send out the number of the currently selected toggle à la radiogroup). Whenever it gets any input, it sets all toggles to 0, resets the input toggle to 1, and sends out the inlet number in which the message was received.

n871's icon

@Wetterberg: you are right..I got a little confused, and I somehow forgot that bangs are also possible to be controlled by midicontrols.
I also liked to use toggles because of their UI :) Looking forwards to the Max 7 toggles, they look very nice.

@Christoph: thank you for your explanation and very clean patch, it is working perfectly and reminds me of the fact that I use way to many trigger objects
in my patches, I should make more use of the basic right-to-left priority.

Thanks again for your time guys!

mradentz's icon

This might help (?). If you perhaps replace the led objects with toggle objects & get rid of the midi stuff. good luck in your patching!

ledSwitcher.maxpat
Max Patch
Roman Thilenius's icon

each button, when clicked, must first reset all others to 0, then do what it is supposed to do:

button1
|
[t whateveritshoulddo 0 0 0]
| | | |
| [change][change][change]
| | | |
aim, button2, button3, button4

the [change] is important - to avoid stack overflow.

-110