Nikita Egorov wrote:
> Hi, I'm sorry for bad news - yesterday I had found one more bug.
> [..]
> The method Fl_Menu_::remove() doesn't remove last item in menu.

        So in other words, it sounds like the following has no effect:

                if ( menubar->size() > 0 ) {
                    menubar->remove(menubar->size()-1);
                }

        I think I can confirm this.

        However, isn't the last item in the menu array NULL?
        ie. if you add three items to an empty menu:

                menu->add("One");
                menu->add("Two");
                menu->add("Three");

        ..I believe the menu's size() will be 4, where the last item is a NULL,
        which I don't think one is supposed to be able to remove.

        I think there are many indexes in a menubar that shouldn't be removed
        (ie. where remove() should be ineffective), such as the NULLs that
        end submenu hierachies. Which is why I think there are tests for NULL.

        To clear the menu, one can use clear(), and to remove individual
        items, I usually find the index name of the item I want to remove
        using find_item(<menu_pathname>).

        I feel I can never trust indexes or pointers to menu items;
        both can go stale if items are add()ed, or something internally
        triggers a copy() operation that makes pointers invalid.

        This is why I added find_item() and its complement, item_pathname(),
        so that one could work with menu names instead of pointers.

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to