[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Copying a lua function to a c++ function
- From: Sergio Garces <sgarces@...>
- Date: Thu, 24 Jul 2003 15:23:03 +0200
Off the top of my head, here's how I'd try to do it:
Have the OnClick function in your Button class call some function
object, that must be passed as a parameter and stored previously.
Then, when you create the button in Lua, you create an instance of that
function object (or a subclass) that contains a reference to the Lua
function (maybe using the registry). You store the function object
together with the instance of the Button and call it when the OnClick
event arrives.
There are no unwanted dependences because the Button class only knows
about the interface that the function object must implement. The actual
implementation (that does depends on Lua) is hidden in the creation of
the function object, that happens in a function called from Lua.
Sergio.