Hi! Sorry for the delay, it's been a busy week. But I am so glad to see you back and working on your project!
This might be a little confusing but I'll do my best... we're going to change the MacWindow contraption a little bit. I'll explain the changes, and also just post a code block for the modified version afterwards in case that's more helpful to you.
There are two draggable canvases inside of the MacWindow contraption.
One is at the top and lets you move the window around the screen. The other is the one in the bottom corner that lets you resize the window.
Inside of the scripts for both of these internal canvases they already have on release do event handlers that are doing something else.
But since we'd also like them to do something when people "release" the contraption on the card (checking for buttons, then locking them) we can add a line saying "card.event.release" to both of the scripts:
on release pos do field.locked:card.locked card.event.release # This is the new line end
This lets the release event from these canvases (when the window is moved or resized) also bubble up to the script for the MacWindow that you have on the card. And that lets us write another "on release do" event handler there, which does something specific to the card it's on.
Or, alternatively, here's the modified version in a codeblock:
%%WGT0{"w":[{"name":"macFieldWindow1","type":"contraption","size":[134,93],"pos":[193,184],"locked":1,"script":"on close do\n \nend\n\non resize do\n \nend\n\nbuttonset:button1,button2,button3\n\non release do\n each button in buttonset\n button.locked:rect.overlaps[me button]\n end\nend","def":"macFieldWindow","widgets":{"close":{},"resize":{"pos":[113,4]},"title":{"size":[37,17],"pos":[48,1],"value":"Hello"},"drag_resize":{"pos":[118,77]},"field":{"size":[133,59],"locked":1,"value":{"text":["I am a draggable and resizeable window sporting a rich text field!\n","Try me!"],"font":["","menu"],"arg":["",""]}},"bar":{"size":[134,19]}}}],"d":{"macFieldWindow":{"name":"macFieldWindow","size":[59,71],"resizable":1,"margin":[22,34,33,33],"description":"a window frame in the style of MacOS 6, sporting a field as well as supporting dragging and resizing! The internal field is available at x.field\nThis version has added an \"on release do\" event.","version":1,"script":"on get_title do title.text end\non set_title x do title.text:x end\non get_field do field end\non get_value do field.value end\non set_value x do field.value: x end\n\non view do\n field.locked:card.locked\n t:get_title[]\n if count t\n title.font:\"menu\"\n s:first title.font.textsize[t]\n title.size:(s+10),title.size[1]\n title.pos :(.5*card.size[0]-title.size[0]),title.pos[1]\n title.show:\"solid\"\n else\n title.show:\"none\"\n end\nend","template":"on close do\n \nend\n\non resize do\n \nend\n\non release do\n\nend","image":"%%IMG3ADsARwbAgHBILBqPyKSyCGo6n9CodEqtgobWrHYbxXK/YCnWeFWWl2Mz2dulBsLvZ/w6TRPp9TP6PW/O+UxsUH2DcIV+dUJ6ioRyi0t4Tn+PZ3mWX4STYoyBbo9qZIhrimKeYI2SiYB3qKJ7jJ6jra2RXLSznKygr5+6vmHAwILBxFbDxchdr8vMzADP0NHS09TV0rSDQtbb3NyNqEPd4uPPmbV+2uTq1n2akunr8dHuiO8B8vjl9Ydn+fh8psL5i8dEjp2BBFM5sodwHb1aAhuOe9gOnsRuf0Khu3dRHDaDHDt62xJRJLtmJkdqKZly2keGLau93BhTJkmLNaHN7JfzGsqe826GBApgJ8ueGQvSJKpvn9OjOSmCZNr0XMWhQJVuXEW16LmFUGvGAQeTqdSyRNspRJu10DecSNsowxp3ZbO7eI+U4ndp7cIsx0j97YtOLmDBogwTpmPuUza1i5zuLQi5sT2/Cj+O3Ysn06+v9TRLzix50piAxkan2vx3lerOqUHDtrpaMFnZpA2P1eg68x3coX9DVt17tWLOxgeTDfwttkHFyxFjBv719tZA0k1pd24sr3e8Rb+LRxME","attributes":{"name":["title","value"],"label":["Title","Text"],"type":["string","rich"]},"widgets":{"close":{"type":"button","size":[11,11],"pos":[9,4],"script":"on click do\n card.event[\"close\"]\nend","style":"invisible"},"resize":{"type":"button","size":[11,11],"pos":[38,4],"script":"on click do\n card.event[\"resize\"]\nend","style":"invisible"},"title":{"type":"field","size":[8,17],"pos":[-12,1],"locked":1,"font":"menu","show":"none","border":0,"style":"plain","align":"center"},"drag_resize":{"type":"canvas","size":[14,14],"pos":[43,55],"script":"on click pos do\n field.locked:1\nend\n\non drag pos do\n card.size:(me.offset-card.pos-16)|(title.size[0]+57),85\n view[]\n field.locked:1\nend\n\non release pos do\n card.event.release\n field.locked:card.locked\nend","show":"transparent","border":0,"draggable":1,"scale":1},"field":{"type":"field","size":[58,37],"pos":[0,18],"border":1,"scrollbar":1},"bar":{"type":"canvas","size":[59,19],"pos":[0,0],"script":"on click pos do\n field.locked:1\nend\n\non drag pos do\n card.pos:me.offset\nend\n\non release pos do\n field.locked:card.locked\n card.event.release\nend","show":"transparent","border":0,"draggable":1,"scale":1}}}}}
No more worrying about the contraption! Back to your cards, where we can modify the scripts inside each instance of the MacWindow in your project.
buttonset:button1,button2,button3 on release do each button in buttonset button.locked:rect.overlaps[me button] end end
AND we need to do some important setup to define "rect.overlaps" and to customize "buttonset" for your project.
To get the rect module, we'll need to transfer it over from examples/draggable.deck.
Decker > Resources... then select draggable.deck in the example folder and transfer "rect" to your current project.
To customize buttonset, you'll need to modify the list of the buttons that you want to lock/unlock when the MacWindow is over them. I just wrote a generic list while testing.
buttonset:button1,button2,button3
This can be in the MacWindow's widget script if there's only one mac window per card, or you can put it in the Card script if you have multiple MacWindows and they all need to lock/unlock the same set of buttons.
The reason why I'm defining the set of buttons this way instead of looking for every button on the card is because I figured that you might have some buttons that need to stay locked until something specific happens in the story... And if you do have special buttons like that, then you can put those specific button in a separate If statement.
on release do each button in buttonset button.locked:rect.overlaps[me button] end if somethinghappened.value specialbutton.locked:rect.overlaps[me specialbutton] end end
Hopefully that will stop your story-related buttons from unlocking before they're supposed to.
I think you're all set on the zazz.wave stuff? So moving on to the music...
You might be able to skip the slider, but in either case, we're using grid.row to find the currently selected row.
If you want to move that value (the number of the selected row) over to a slider and use it from there, then you could do something like this inside the Grid's script:
on click row do songslider.value:songgrid.row end
And then inside the button you can do something like this if you're using the slider... (Remember that numbers start counting at 0!)
on click do if songslider.value=0 play["firstsong"] elseif songslider.value=1 play["secondsong"] end end
Or if you'd like to skip the slider you can check the selected grid row from inside of your button like this:
on click do if songgrid.row=0 play["firstsong"] elseif songgrid.row=1 play["secondsong"] end end
Depending on the number of songs you're dealing with you may have a lot of elseif elseif elseif to add to your button script, and if that's true then you might want to switch over to using a table instead at some point... but if it's only a couple of them then this should be fine.
I'm also not sure what you're doing with your music, so I just put the generic play[] function there for now.
As always, change the names to the actual names of your widgets and songs and I'll try to be around to answer any more questions you may have!