News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Adding and Extending Widgets
Author Message
Juergen
Member
***


Posts: 81
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #1
RE: Adding and Extending Widgets

mikshaw Wrote:
After seeing Juergen's demonstration of extending widgets with new methods, and William's post about adding new widgets, I went back to the FLTK documentation about subclassing hoping I could translate this to murgaLua. Unfortunately I know nothing about C++ and not enough about Lua to do the translation, or even to learn if it's possible to do this with Lua.

Would anyone be willing to put forward a guess as to whether it's possible to use murgaLua to create a new subclass of Fl_Widget, maybe by putting together a collection of existing widgets?


No you can't do the same as in C++ just by adding or changing a few functions/methods from within Lua. But you can of course do some pseudo OO programming with Lua and it would be possible with some metatable magic and a few proxy functions to define something like subclasses (although in a limited fashion).
For example:

Code:
Fl_Menu_Bar.callback_old=Fl_Menu_Bar.callback
function Fl_Menu_Bar:callback(cb) print("New callback!") self:callback_old(cb) end

You will see the message when you call menu:callback(my_cb) but not when you call menu:add("item",0,my_cb)

There are a lot of places and quirks that have to be insert to make subclassing in Lua useful.

Although it might be interesting to do some further research.

Juergen

02-11-2008 11:08 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
Adding and Extending Widgets - mikshaw - 02-09-2008, 12:44 PM
RE: Adding and Extending Widgets - Juergen - 02-11-2008 11:08 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: