How to get the selected objects in a patcher?

Oct 21, 2013 at 9:25am

How to get the selected objects in a patcher?

Hi there,

it seems like a pretty simple action to perform but could not find a way to do it.
So, is it possible to get a t_linklist of user selected objects/boxes in a patcher/patcherview?

After some investigation of the Max/MSP SDK, I deduce that the object selection information must be part of the patcherview data structure and not the patcher.
Now the patcherview has an attribute named “selectedboxes” that might be what I am looking for.
Obviously I have no way to know how the underlining data is organized and any attempt I made to get at the selection info failed miserably…

Anybody could give me a hand?

Thank you.

- Luigi

#268627
Oct 22, 2013 at 5:19am

Hi Luigi,

Perhaps the code of hoa.connect could help you (hoa.connect.c -> notify method). https://github.com/CICM/HoaLibrary/tree/master/Max6/hoaFamily

Cheers

#268729
Oct 22, 2013 at 5:52am

Hi,

Thanks Pierre (i spent all my morning searching the trick)!

#268736
Oct 22, 2013 at 10:01am

Yes, that’s it!
Gotta love the Max/MSP forum…
Thanks Pierre for your help.

Best

- Luigi

#268762
Oct 27, 2013 at 11:14am

Ok, after further investigation I was able to determine that the overall strategy doesn’t work reliably.
Let me explain: as things are coded right now both in my external and in Pierre’s hoa.connect, the objects attach to the patcherview and start receiving notifications from it. The ‘selectedboxes’ notification allows to assess what objects are currently selected in the patcherview.

…and here lies the problem…

The ‘selectedboxes’ attribute is an attribute of the patcherview and not of the patcher. So different patcherviews refer to the same patch but might have different objects selected. However the patcherview being monitored for notifications by our external is always the same. The problem arises when the user creates more than one patcherview and starts editing around the different views. Even worse than that, the user could potentially close the patcherview to which we are attached and just continue working and editing a different patcherview.

So the solution would be to know the active/frontmost patcherview and to always attach to that one.
Intuitively, I am thinking it could be an attribute of the patcher – which view of that patcher is the active one.
So if we attach to the patcher we could get notified when the active patcherview changes.

Am I thinking along the right lines?
Does anybody know how to achieve that?

- Luigi

#269271
Oct 27, 2013 at 11:37am

?

https://github.com/nicolasdanet/Flop/blob/master/Sources/Flip/flopSelected.c#L155

I spent long time to manage multiple views in [quebec] ; it’s not fun at all. I have no idea what your external is supposed to do, but perhaps you could grab tricks inside it ( https://github.com/nicolasdanet/Quebec/blob/master/Sources/Quebec/Quebec.c ).

#269274

You must be logged in to reply to this topic.