Implementing event handlers with LUA

View: New views
2 Messages — Rating Filter:   Alert me  

Implementing event handlers with LUA

by Juan Manuel Alvarez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi! I am implementing a GUI system and I would like to handle the
widgets events in Lua.

I would like to do something like:

[C++]
Button* b;
b->setOnClickEvent("myClick");

[LUA]
function myClick( w )
    w.Text = "clicked"
end

but I cant find how to bind the parameter in Lua with the object in
C++ with SWIG.

Can anyone point me in the right direction?

Thanks in advance!

Juan M.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Parent Message unknown Re: Implementing event handlers with LUA

by mark gossage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Hi! I am implementing a GUI system and I would like to
> handle the
> widgets events in Lua.
>
> I would like to do something like:
>
> [C++]
> Button* b;
> b->setOnClickEvent("myClick");
>
> [LUA]
> function myClick( w )
>     w.Text = "clicked"
> end
>
Hello Juan,
Its currently not so easy to write callback in Lua within SWIG.
You can look at SWIG/Examples/lua/funcptr3 which shows how pass Lua functions to C.
You can also look at SWIG/Lib/lua/lua_fnptr.i which is the code to use it.

Let me know if you have any other questions.
Regards,
Mark


     

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user
LightInTheBox - Buy quality products at wholesale price!