How to get the selected objects in a patcher?
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?
Perhaps the code of hoa.connect could help you (hoa.connect.c -> notify method). https://github.com/CICM/HoaLibrary/tree/master/Max6/hoaFamily
Yes, that’s it!
Gotta love the Max/MSP forum…
Thanks Pierre for your help.
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?