Assuming this is readable this time... (and not more B64 nonsense...) > 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)); > ... > } What is it you are trying to do here? Pass a numeric value into the callback in the userdata, I think; but you are doing it by passing a string than calling atoi() on it... > but that seems a little cumbersome and inflexable. Indeed. Worked example below. > I notice that old examples used > int i = (int)v; > but that won't work with gcc-4.4.5 Huh? Should do. We might need to see your code. Just tested with gcc 4.7.2 and that works fine... > Will fltk-3 provide more flexibility? No, it is the same. For now, fltk-1.3 is the recommended build, it is stable. Fltk3 less so... // // fltk-config --compile menu-userdata.cxx // #include <FL/Fl.H> #include <FL/Fl_Double_Window.H> #include <FL/Fl_Menu_Bar.H> #include <stdio.h> static Fl_Double_Window *main_win=(Fl_Double_Window *)0; static Fl_Menu_Bar *menu_bar=(Fl_Menu_Bar *)0; enum eop { task0=200, task2, task3}; static void cb_item1(Fl_Menu_*, void *v) { int i = (int)v; printf("Menu got %d\n", i); fflush(stdout); } Fl_Menu_Item menu_menu_bar[] = { {"A Menu", 0, 0, 0, 64, FL_NORMAL_LABEL, 0, 14, 0}, {"Item 1", 0, (Fl_Callback*)cb_item1, (void *)task0, 0, FL_NORMAL_LABEL, 0, 14, 0}, {"Item 2", 0, (Fl_Callback*)cb_item1, (void *)task2, 0, FL_NORMAL_LABEL, 0, 14, 0}, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0} }; int main(int argc, char **argv) { { main_win = new Fl_Double_Window(356, 231, "Test Window"); { menu_bar = new Fl_Menu_Bar(0, 0, 356, 20); menu_bar->menu(menu_menu_bar); } // Fl_Menu_Bar* menu_bar main_win->end(); } // Fl_Double_Window* main_win main_win->show(argc, argv); return Fl::run(); } ///////// end of file /////////// _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk