IDs of MenuItems are weird

Hello,

I’ve created a menubar with four (!) items. I set the command to

        Command click = new Command() {

            @Override
            public void menuSelected(MenuItem selectedItem) {
                Notification.show("Clicked " + selectedItem.getId());
            }
            
        };

The notifcations shows …

  • … “Clicked 2” for the first item
  • … “Clicked 3” for the second item
  • … “Clicked 4” for the third item
  • … “Clicked 5” for the fouth item

However, I would excpect to see “Clicked 0”, “Clicked 1” and so on or at least “Clicked 1”, “Clicked 2” …
Why are the ids of MenuItems that strange? And are they reliable? Can I use them to refer to a particular item?

Thanks :slight_smile:

Knee-jerk reaction says that item 0 is the menu bar itself, while item 1 is the submenu container.

Ah, thank you :slight_smile: