Creating an object that responds to a click / double-click

discopatrick's icon

I quite like the way that a [loadbang] can be made to bang again later by double-clicking it.

How do I add this to my own object?

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

one way with timer:

discopatrick's icon

Yes, I see what you've done.

But isn't there a way of tapping into the operating systems double-click event? Rather than trying to recreate the event ourselves?

I like what you've done, but the double click is set to a fixed time, whereas in a operating system you define this time through your system-wide preferences.

discopatrick's icon

Also, your example shows how to respond to a double click within a patch.

I want to be able to double-click my own object - they same way you would double-click a [loadbang].

goodparleyandorfing's icon

Surely you are referring to external development? An abstraction would only open the patcher window, in which case I suppose [active] could work in a roundabout way.

I've not heard of a function that recognises double-clicking your external as a bang, but if you ask in DEV forum I'm sure someone will be able to help.

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

mmm... if you want to detect dbl-clicking in a max patch, why not use loadbang?

... if you want a custom external to respond to double clicking, then you can implement the dblclick method - iirc, the index~ example should show it!

hth
aa

goodparleyandorfing's icon

I posted before seeing these replies. The way to access mouse data in max is via [mousestate], but you will still encounter the problem I mentioneddue to the difference between abstractions and objects

discopatrick's icon

goodparleyandorfing - you are right... double-clicking my own abstraction will cause the patch to open. I forgot about that. So I guess an external is the only way.

Thanks all.

$Adam's icon

Hi,

if you need to detect the 'true' double click (that is, the double-click that the OS will send you based on global settings about sensitiveness of the mouse etc) then you need to make an external. If you just want to 'emulate' double-clik (that is: you set the threshold between subsequent clicks in Max), then you can use the following small example patch based on the [lcd] object:

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

Just double-click on the [metro] object in my example! It will turn the metro on. Oh, and don't forget to set the threshold time in the 'basic stuff' part! ;-)

Hope this helps,
Ádám