[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: How do people resolve the following using lua/c++
- From: Nick Trout <Nick.Trout@<a href="/cgi-bin/echo.cgi?warthog.co.uk">...</a>>
- Date: Mon, 25 Feb 2002 11:36:53 -0000
> I am currently storing an extra pointer in my button class which i
> simply check for when the function in c++ is called, if it is set
> to NULL i just call the default behaviour, otherwise i call the lua
> this is the only 'easy' way i can see to do this although i'm
> guessing it may become a maintenance nightmare later on...
> how do people normally go about resolving this kind of situation ?
That sounds like a fair solution. Your maintainance problem being that you
have to wrap each control and callback references for the scripting. Then
you expose the control interface and its event handlers. This is a C++
If your GUI system uses event messages to drive it then you could pass
messages back and forth between C++ and script to manipulate the controls.
Event handlers could be tagged onto control instances and event messages
intercepted and dealt with in script. Here you just expose the control
interface and a message listener handler which handles all event listening.
Basically there is no mechanism for attaching virtual overridden functions
to control instances in script at runtime per control. So, you either wrap a
control type and test in C++ if its overidden, or avoid this mechanism and
use messages and test in script.
You could look at wxPython for ideas. I'm not sure how it works myself but I
know you register event handlers per control.