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 
Initial build of version 0.6.0
Author Message
Senior Member

Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: Initial build of version 0.6.0

Messing around with the menu example, I made a couple of changes that cut down the size a little, although it might not be as easy to read. Mainly I just like to see how small I can make things.

testItem=menuBar:find_item("Second menu item/&First item");

is replaced by

menuBar:find_item("Second menu item/&First item"):user_data("testFunction()")

and the callback (just the part that runs testFunction) is

local s=w:mvalue():user_data()
if s then assert(loadstring(s))() end

I don't know if io.flush is still needed? Actually I don't know if I should be using it in other scripts too.

It didn't look at first as though this was any simpler than making a bunch of elseif statements in a single callback, but it seems that this is the next best thing to assigning callbacks directly to menu items.

It still seems like there should be a simpler way than loadstring, since the string is already static and in memory, but since you plan to eventually attack the callback this will be fine.

01-20-2008 08:34 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
Initial build of version 0.6.0 - JohnMurga - 01-19-2008, 08:30 PM
RE: Initial build of version 0.6.0 - znarf - 01-20-2008, 12:07 AM
RE: Initial build of version 0.6.0 - mikshaw - 01-20-2008 08:34 AM

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

Forum Jump: