Click and drag

joedan06's icon

I'm pretty new to MaxMSP and I have multiple toggle box's and i want to be able to click once and just drag the mouse around and if a toggle box is hit i want to toggle it. Is there a behavior or something for that?

Roman Thilenius's icon

no.

you can at any time program something like that on yourself
in maxmsp, but there is no default for such kind of mouse
behaviour.

it can surely be made by putting an ubutton object over the
toggles and program some custom logic and math for the ubutton
output which controls the toggles so that it feels like as if,
if you know what i mean.

probably not the easiest thing to program for someone new
to max, but i do not want to disencourage you to try it.

try it!

-110

joedan06's icon

looking at the ubutton outputs, which one would need to be utilized because when thinking about it, i can't wrap my head around which one would be able to know in advance if the mouse is already clicked. This max is very weird when I'm self teaching it to me .. lol

Tim Lloyd's icon

If you're a complete beginner this patch might be a bit confusing - but take the time to look through the help file and reference of each object. Also keep in mind the if object is not as confusing as it looks at first, just try experimenting with it to see what it can do.

I've commented the patch and left you 2 things to work out for yourself if you can, sorry if some of it seems patronising!

Something I'm not sure about is if there is a way of "getting" the patching rectangle of an object automatically without the need to copy and paste....

anyway - here you go:

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

(just in case you don't know - copy all the gibberish including the ----start/end_max5_patcher---- text, and choose File > New from Clipboard)

Roman Thilenius's icon

mouse up or down:

[t 0], [t 1]

but whatever, i was giving you wrong advise anyway, [ubutton]
does not report drag location.

[mousetrack] is unsupported, and just like the standard
object [mousestate], difficult to use for only a region
in a patch.

what works great for mousetracking in a region is to abuse
the [lcd] object, which is able to report drag position when
put in background behind your UI.

(one exception: lcd´s idle mousing does _not work in _pluggo.)

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

-110

-

Tim Lloyd's icon

Cool, check out RT's patch, its a much better method for what you want to do.

Although it wouldn't work for my experiment I took my suggestion from

Luke Hall's icon

If you can cope with using keyboard buttons instead of the mouse button then you could use the method in the patch below. It won't work otherwise because [hover] doesn't report scripting names while the mouse button is pressed. The [toggles] all have unique names. Holding down the 1 key will turn them on, the 2 key will turn them off.

lh

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

joedan06's icon

Thanks for all you help! I think I got it figured out!

Roman Thilenius's icon

oh btw: it is more interesting to learn how to make
your own, but [matrixctrl] also does what you need!

seejayjames's icon

timlloyd wrote on Mon, 20 July 2009 19:28
Something I'm not sure about is if there is a way of "getting" the patching rectangle of an object automatically without the need to copy and paste....

I think you can by using [pattr @bindto patching_rect], which can also work for (most?) other attributes. This could keep track of what you do with your objects when using the Max interface itself, rather than tracking them using "patching_rect $1 $2 $3 $4" message in a locked patch. So both ways are possible, plus presets can be used to store various UI layouts, cool (floating windows/subpatches can also be used this way).

The [tab] object also reports hovering, so maybe with some sort of alpha trickery you could use them and not see them. Note that if your toggle is being "clicked" through some other means (like the lcd, tab, ubutton etc.), you can actually make it Ignore Click... which will make things simpler anyway.