Murga-Projects Forums
Development resumes - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: Development resumes (/showthread.php?tid=323)


Development resumes - JohnMurga - 06-12-2008 08:13 PM

Hi,

As some of you know I've been away for a quite a while ...

Either way I am back now and I am going to resume development of murgaLua version 0.6.9.

The focus is really to document things and tidy up things to the point that a general public release is possible ... Please report any issues that should be fixed for the next release.

Cheers
JohnM


RE: Development resumes - znarf - 06-16-2008 09:35 PM

JohnMurga Wrote:
... Please report any issues that should be fixed for the next release.


The usage of Fl_Menu_Item user_data is not clear to me and might either need some documentation or an extension of the Fl_Menu_:value(...) method:

In my case I store the text corresponding to an Fl_Choice menu item in a settings file. When I reload a previously saved settings file later on and try to set the Fl_Choice widget according to the text, there is the inherited method Fl_Menu_:find_item(text) method which allows me to retrieve the corresponding menu_item user_data. However, unlike in C++ fltk, a call to Fl_Menu_:value(user_data) does not work, apparently only the Fl_Menu_:value(index) version has been translated to lua. Therefore, as a work-around, I currently have to determine the index by looping over the user_data returned by Fl_Menu_:menu(i) and compare the texts manually. This is pretty cumbersome. Also, unlike one would expect in Lua, one has to loop like in C++ from 0 to Fl_Menu_:size()-1.

My suggestion to improve this would be an extension of the Fl_Menu_:value() method to allow also menu item user_data as input.

[Update]
Additionally, calls to Fl_Menu_Item:labelsize() seem currently useless. They always return 0 irrespectively to any value passed before.

Regards,
Gerald


RE: Development resumes - JohnMurga - 06-17-2008 12:27 AM

znarf Wrote:
The usage of Fl_Menu_Item user_data is not clear to me and might either need some documentation or an extension of the Fl_Menu_:value(...) method:

In my case I store the text corresponding to an Fl_Choice menu item in a settings file. When I reload a previously saved settings file later on and try to set the Fl_Choice widget according to the text, there is the inherited method Fl_Menu_:find_item(text) method which allows me to retrieve the corresponding menu_item user_data. However, unlike in C++ fltk, a call to Fl_Menu_:value(user_data) does not work, apparently only the Fl_Menu_:value(index) version has been translated to lua. Therefore, as a work-around, I currently have to determine the index by looping over the user_data returned by Fl_Menu_:menu(i) and compare the texts manually. This is pretty cumbersome. Also, unlike one would expect in Lua, one has to loop like in C++ from 0 to Fl_Menu_:size()-1.

My suggestion to improve this would be an extension of the Fl_Menu_:value() method to allow also menu item user_data as input.

[Update]
Additionally, calls to Fl_Menu_Item:labelsize() seem currently useless. They always return 0 irrespectively to any value passed before.


Hi,

I'll look into this for 0.6.9, could you post some code to illustrate the issues ? It'll make it that much easier for me to resolve them.

Cheers
JohnM


RE: Development resumes - mikshaw - 06-18-2008 12:14 AM

I spent much too long on this yesterday, thinking it was a simple solution, but eventually realized it doesn't behave as documented, "You can set it as an integer, or set it with a pointer to a menu item."

Here's what I was playing with:

Code:
my_menu=fltk:Fl_Choice(10,10,120,30)
for _,i in pairs({"one","two","three","four"}) do my_menu:add(i) end
my_item=my_menu:find_item("three")
my_menu:value(my_item)




RE: Development resumes - znarf - 06-20-2008 05:02 AM

Hello Mikshaw,
thank you a lot for your efforts to interpret my original posting lacking an explicit example, yes your code snippet captures the essence of the reported first issue.
An analogous example for the second issue would be

Code:
menuBar=fltk:Fl_Menu_Bar(0,0,100,20)
menuBar:add("File/Load settings...")
menuBar:add("File/Save settings...")
menuBar:add("Help/About...")
for i=0,menuBar:size()-1 do
    menuBar:menu(i):labelsize(12)
end

When I tried it today while writing this example, it worked flawlessly! So please apologize and ignore the erroneously reported second issue.

Regards,
Gerald