marty moore
2013-04-03 15:44:05 UTC
Hi all,
Please excuse another newbie question.
I'm looking at storing an enum as user data in an Fl_Menu_Item user data. In the callback, I want to access the enum.
I know that I can put the enum into user data as a string:
enum eop { task0=200, task2, task3};
Fl_Menu_Item menu = {
{ "thing 1", 0, mycallback, (void*)"201"} .... }
void mycallback(widget* w, void* v)
{ ....
eop e = (eop) (atoi((char*)v));
...
}
but that seems a little cumbersome and inflexable.
I notice that old examples used
int i = (int)v;
but that won't work with gcc-4.4.5
I tried subclassing Fl_Menu_Item, but couldn't get it to work.
Is there a better way?
Will fltk-3 provide more flexibility?
Should this be covered in a tutorial? I couldn't find anything in search.... which surprised me. It seems like it should be covered somewhere for newbies.
Thanks,
Marty
Please excuse another newbie question.
I'm looking at storing an enum as user data in an Fl_Menu_Item user data. In the callback, I want to access the enum.
I know that I can put the enum into user data as a string:
enum eop { task0=200, task2, task3};
Fl_Menu_Item menu = {
{ "thing 1", 0, mycallback, (void*)"201"} .... }
void mycallback(widget* w, void* v)
{ ....
eop e = (eop) (atoi((char*)v));
...
}
but that seems a little cumbersome and inflexable.
I notice that old examples used
int i = (int)v;
but that won't work with gcc-4.4.5
I tried subclassing Fl_Menu_Item, but couldn't get it to work.
Is there a better way?
Will fltk-3 provide more flexibility?
Should this be covered in a tutorial? I couldn't find anything in search.... which surprised me. It seems like it should be covered somewhere for newbies.
Thanks,
Marty