> I think the following is actually a kind of cool solution.
>
> I should make use of it, as I've run into this myself.
> Let me know if it seems workable. Maybe the docs for add()
> should recommend this in cases where one wants to have
> slashes in the label for certain menu items.
>
> To solve this correctly, maybe there should be a version of add()
> that lets one specify the delimiter character to use, and if set
> to 0, it would not parse for delimiters /at all/.
>
> Greg Ercolano wrote:
> >> Anyway, I will also submit a bug/feature request for a solution.
> >
> > This might be the easy answer:
> >
> > #include <FL/Fl.H>
> > #include <FL/Fl_Window.H>
> > #include <FL/Fl_Menu_Bar.H>
> > //
> > // Demonstrate how to add pathnames as menu items
> > // erco 12/10/07
> > //
> > int main() {
> > Fl_Window *win = new Fl_Window(400,400);
> > Fl_Menu_Bar *menu = new Fl_Menu_Bar(0,0,400,25);
> > menu->add("File/Open");
> > {
> > int i;
> > Fl_Menu_Item *m;
> > i = menu->add("File/Open Recent/x"); m =
> > (Fl_Menu_Item*)menu->menu(); m[i].label("/some/path/to/foo.ext");
> > i = menu->add("File/Open Recent/x"); m =
> > (Fl_Menu_Item*)menu->menu(); m[i].label("/some/path/to/bar.ext");
> > i = menu->add("File/Open Recent/x"); m =
> > (Fl_Menu_Item*)menu->menu(); m[i].label("/some/path/to/blah.ext");
> > }
> > win->end();
> > win->show();
> > return(Fl::run());
> > }
> >
> > Just add() the menu item, using "x" in place of the label that
> > might contain slashes, then change the label() of the returned menu item
> > immediately afterwards.
> >
> > I think it's only the add() method that's interpreting the slashes
> > as submenus, so if you change the label after add()ing the item,
> > that should be safe.
> >
> > If that works, you can probably make that into a function.
This indeed seems like a good workaround, although I tried it and had some
segmentation faults when using non constant labels, it was probably my fault
but I did't test throughly. The theory seems right though.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk