I’d like to achieve the result of right click menu that happens in every pc/mac enviroments (here for semplicity is done with left click, but an example shoud be right clicking on desktop of mac/pc).
Based on your description (here for semplicity is done with left click) , I’m guessing that this should be inside of a Component::mouseDown() override, not a Button::Listener::buttonClicked() override?
thank you for reply, but I’ve just tried overriding mouseDown in mainComponent and put inside previous code, nothing happens again and instead (as before) error is rised inside juce_PopupMenu.cpp line ~1432:
// An ID of 0 is used as a return value to indicate that the user
// didn’t pick anything, so you shouldn’t use it as the ID for an item…
the assert is telling you what is wrong. You are adding a menu item with the id of 0, which per the documentation (and the assert) is invalid. You need to set the itemID member for each of your PopupMenu::Item's, and they need to be non-zero. These id’s will be how you know which item of the menu was selected (or a 0 id will be returned if no item was selected).