This is a script-only stack that allows your application to listen for and broadcast internal notifications. Similar to NSNotificationCenter
Why would I use this
While you can probably do something very similar with 'send' and 'dispatch' (heck, the code is written using dispatch) you would need to know the target objects and adding new objects to your project would require you to make sure that you remember to update your code.. If your project has loadable stacks, this makes it even easier for you to have those stacks interface with your main application without even knowing anything about it..
Sounds weird, but how does it work
First thing you would need to do is to load the script and then bring it in to use with the "start using" command..
Now, any objects that you want to register you just call the 'Listen' command, along with a notification name (explained better below)
And finally, your code can send out notifications with the 'Notify' command..
Quick and dirty docs
To bring the stack in to use
Code: Select all
start using stack "SSNotification"
Code: Select all
Listen "notificationName"
Code: Select all
Notify "notificationName"
Quick and dirty sample
the script stack has been loaded in to memory and brought in to use already
Button A
Code: Select all
on mouseUp
Listen "anotherMouseUp"
end mouseUp
on anotherMouseUp buttonName
put buttonName
end anotherMouseUp
Button B
Code: Select all
on mouseUp
Notify "anotherMouseUp", the short name of me
end mouseUp
Clicking on button B will cause it to send out the notification "anotherMouseUp" with a single parameter (the button's short name)..
ps.. yes, i suck at documentation, anyone want to do a better job?
Okay, this sounds like it was written by a baboon, but I'll try it anyways
https://shaosean.tk/SSNotificationLiveCode.html