To get this kind of itegratin with scripting, you need a ScriptingModule object specific for the scriptig language you are targetting. Using this it will then be possible to get gui events to call script code like in demo 8.
There is no source code for demo 8 as such, it was entirely done via script and the config file (IIRC). What made demo 8 possible was my (abandoned) ScriptModule using luabind, I am willing to give this out, but what you need to realise is that the code is totally out of date with the current system, so will not compile or work properly without a lot of modifications. I will say now that no support for this code will be provided what so ever - it was abandoned for good reason
I do intend to supply at least one example ScriptingModule at some point in the near(ish) future.
Let me know if you still would like to see the source for the ScriptingModule and I'll upload it somewhere.
CE.