Getter for PopupMenu::Item?

I would like to be able to take one menu and append it to another, a bit like this pseudo-code:

PopupMenu menu1 = PopupMenu {item1, item2, item3};
PopupMenu menu2 = PopupMenu {item4, item5, item6};

PopupMenu combinedMenu = menu1.appendMenu(menu2); // or any other way of joining the two menus
// combinedMenu now = {item1, item2, item3, item4, item5, item6}

This seems like a simple task, but I can’t seem to find a way of doing it, because there are no getter methods in the PopupMenu class. I can think of three possibilities, but none of them seem to be allowed:

  1. A Item* PopupMenu::getItem(int) method, which would allow you to fetch menu items and copy them;
  2. A void PopupMenu::appendMenu(const PopupMenu&) method, which would allow you to join menus directly, as imagined in my pseudo-code;
  3. .begin() and .end() iterators which would allow you to iterate over the menu in a for each loop.

Is some other way of doing this that I haven’t thought of?

It’s not a disaster if I can’t get this done, but I’m surprised because it seems like it should be easy. Is there a reason why there are no getters for the PopupMenu class?

It seems to exist as java style MenuItemIterator

Haven’t used it, but I think, it should work roughly like that:

PopupMenu::MenuItemIterator iter (menu1, true);
while (
    combinedMenu.addItem (iter.getItem());

Hope that helps…


Amazing! Thanks for spotting this @daniel–it does exactly what I need.