Store selected items of chooser in pattr
I created a patch with a chooser (with multiselect) that gets filled with items. I can select multiple items. I’d like to store this state (so the items including which ones have been selected) in a pattr so that after saving in Live, I get the same items selected when re-opening this Live set.
Using pattr I can obviously store the items of the chooser, but I can’t get it to store which ones were selected.
how would you do this?
So I tried a lot of things to get it to save both chooser content as well as the selected indices, but still can't get it to do what I want.
I'd guess I'm making a basic mistake. Anybody knows what I'm doing wrong here?

My assumption would be that you'd want separate pattr for the 'saveList' and the selectedindecies and that you'd just need to, on load, restore the selection(s) to the chooser after you know the saveList stuff was restored. However, it doesn't look like [chooser] has any "set" message equivalent that allows for multiple selections. So it may not be possible.
What happens if you just enable "parameter_mode" for the chooser, rather than using pattr?
I just tried removing the pattr and enabling parameter_mode for the chooser (type set to blob or set to enum) but that doesn't save anything. After reloading the chooser is empty.
So are you saying that chooser doesn't have the ability to save anything using either pattr or parameter_mode?
Ah, I thought you were only having trouble with the multiple-selection restoration part, not the entire Chooser contents.
From what it sounds like it doesn't have a way to persist the dynamically-populated list of items. And it also looks like you may only be able to store the/(a single) selected item index:

You could use a [dict] or [coll] to mirror the contents of the Chooser and store them in parameter mode, and then re-populate the chooser from that data when the device is reloaded. But I don't see a way to re-select *multiple* indices programmatically to make the selection look exactly the same in the UI.
How is the Chooser getting populated (or what is it getting populated with, anyway?)
Thanks for checking. The reference https://docs.cycling74.com/max8/refpages/chooser indicated that parameter_enable is available:
parameter_enable [int]
Enables use of this object with Max for Live Parameters
But aparrently it doesn‘t work the way I anticipated. Maybe I just picked the wrong object for the job.
I’m using the chooser as a ui element to simplify muting and unmuting of notes of a clip. My choooser is being populated with a list (of unknown length) of names of samples (eg from a drum rack).
I select one or more samples and upon hitting a mute/unmute button I bang the chooser so it outputs the selected indices. based on the selected names, I mute/unmute the corresponding notes of a midi clip.
reason I chose for a chooser is that it allows for creating a scrollable list where items can be selected. Now I know chooser is usually used to manage files etc but I’m not aware of any other objext that allows for this type of user interfacing.
maybe somebody knows of a better way to accomplish this or similar type of UI?
bummer. I just found this post from 2019 and still not implemented...
https://cycling74.com/forums/request-object-%22chooser%22-multiselect-set-multiselected-items
chooser allows only consecutive multiple selections,
which is another limit.
@SOURCE AUDIO -- not true. See my picture above (selectedindices 0 2 3). Achieved with some modifier key held.
help file mentions only shift key, which does not.
but I tried command on Mac, and you are right - it works.
Why is there no mention of it in help file ?
alright, so Chooser has too many limits for what I want.
I completely reworked my patch, effectively eliminating chooser.
Based on https://cycling74.com/forums/best-way-to-create-a-dynamic-list-of-checkboxes I decided to create a dynamic list of checkboxes in an embedded patcher and use the patchers scroll feature to mimic a chooser.
Anyway, lots of hard work :-)
But there's always a but. Three actually and hopefully someone can help me out:
1. The state of my checkboxes in my radiogroup (checkboxes with "Parameter mode enabled) isn't saved in a Live set;
2. The content of my dict saves properly in my Live set, but when reopening, the coll doesn't get updated (push_to_coll doesn't work?)
3. I add content to the coll and as a result the patcher window becomes large and the scroll bar appears. If I then scroll down and clear the coll, the patcher window doesn't resize. It remains in "scrolling" state (i'd consider this a minor issue)
Attached is my patch for you all to try.
1) radiogroup with Parameter Mode *might* work if you change it from "enum" type to "blob". Dynamic object sizes / value ranges don't play nice with recall in Live. As a workaround it would be easy enough to have a [pattr] which stores the list of bool "checkbox" values and then restores them (… after you've re-populated the items/set the size).
2) [loadmess push_to_coll] triggers before [live.thisdevice]. The parameter value stored in the dict won't be valid until after live.thisdevice.
3) 🤷🏻♂️
thanks, that worked really well!
1) radiogroup in parameter mode blob type didn't work for me, but solved it using the pattr workaround as you suggested.
2) I thought it could be a loading order issue but couldn't find out the root cause. So swapped loadmess with live.thisdevice and things start to work!
3) yeaaahh... would still be nice if someone knows how to fix this, but it's waaaay out of my league :-)
attached my final chooser workaround with multiselect and saveable state!