2008/11/10 Michael Bauroth <Michael.Bauroth@falcom.de>:
Hi, me once more. Have found out, that the code works very well (another
error confused me here). The remaining question is, how to pass a
additional
parameter (in my special case the sender object), when I trigger the
callback?
// push function
lua_rawgeti( L, LUA_REGISTRYINDEX, m_CbOnMouseDown );
// push parameter(s)
lua_rawgeti( L, LUA_REGISTRYINDEX, this );
// XXX doesn't work, needs an integer here :(
// call function
if ( lua_pcall( L, 1, LUA_MULTRET, 0 ) != 0 )
{
TRACE( _T( "Error calling LUA callback OnMouseDown\n" ) );
}
Use lua_pushlightuserdata or lua_newuserdata to pass a pointer to Lua.
For example:
lua_rawgeti(L, LUA_REGISTRYINDEX, m_CbOnMouseDown);
lua_pushlightuserdata(L, this);
if ( lua_pcall( L, 1, LUA_MULTRET, 0 ) != 0 )
{
TRACE( _T( "Error calling LUA callback OnMouseDown\n" ) );
}