scrolling list of filenames that is re-arrangeable

madbutter's icon

Hi folks, I'm trying to create a playlist of files that a user can edit by adding or removing files, and re-arranging their order in the list. I have come up with a solution that populates a [umenu] with a "source" folder full of files and then one can select one of these to write that filename to a [coll] which in turn refers to a [jit.cellblock]. The user can then select a row in [jit.cellblock] and use buttons below it to remove, move up, or move down the selected file  in the list. To do this I take the row info from the [jit.cellblock] selection and send the appropriate delete and swap messages to the [coll], which in turn updates the [jit.cellblock], since there does not seem anyway to do this with [jit.cellblock] alone. This kind of works but one problem I have is that the [jit.celblock] does not update enough to manage keeping the selection in the right place. I see there is an attribute that lets you set the "interval" that the [jit.cellblock] updates itself from the coll. Can I force a single immediate update so the [jit.cellblock] is forced to update before I reset the selection? I know I can delay the selection setting but I've always been under the impression that handling these kind of timing issues with delays shows weak programming practice. What happens if I make the interval really small - I hate to think of wasting cycles checking for an update when it is not needed.

I'm also feeling that my whole solution is too much of Rube Goldberg machine. Someone out there must have done this before using a more elegant technique! After some searching on the forum I was thinking that SQLite may be a better answer for the moving the data around but my biggest problem is still the UI - I don't see another Max object that lets me display an ordered list of undetermined length (but fixed size so that the list turns into a scrolling list at some point) where lines can be selected and removed or moved.

If anyone has any idea it would be greatly appreciated,

Bob

madbutter's icon

Ah yes, it does seems that Andrew Benson's tutorial on SQLite points to the answer to my problems:

I was frustrated that it seemed so awkward to use jit.cellblock to organize and re-order my playlist.  jit.cellblock is the only object I could find that looked right from a UI perspective but my roundtrip solution using coll was clumsy. With Andrew's solution I see that I can use javascript to erase and re-write the whole jit.cellblock every time I make a change to my playlist or its order. I guess it might get slow with lots of data but probably ok for my requirements...