I have a list of songs. Each song is a list comprising a rating for the melody and a rating for the solo.
The interface should present the list of song titles along with an upvote and downvote button next to each title.
My initial thought was to include a Button[] as an element in each list. However, I can’t find a way for the Button to ‘know’ which list it is a member of. In OO based languages there would be the concept of Self, ie. the object that the Button is a member of. Is there something like that in Mathematica. Or, is this completely the wrong way to build the interface?
I do not have time to validate my idea, but I think you can do what you want by identifying the “self” through the action parameter to Button[].
The documentation gives an example of using Print[10!] as the value for action. You should be call different functions, or the same function with different parameters that identify the song.
If you want to programmatically generate the Buttons, then you call use ToExpression[] with the action. ToExpression[] takes a string (that you can generate with the song title).
May not be the most elegant method but you can have the button know its position by generating it with a fixed input, the original order.
The order list is then used to sort the list. Up means changing its current order value with the one above. moving down changing it with the order values below.