ActionPopupMenu icons are not displayed?

Answered

I created a bunch of actions and added them to my ActionPopupMenu. Everything works fine except icons I created the actions with are not displayed in the popup menu. Is it designed to be this way or is there a way to get them displayed? For example,

DefaultActionGroup group = new DefaultActionGroup();
for (Scenario scenario : scenarios) {
boolean isChecked = currentScenario != null && currentScenario.getName().equals(scenario.getName());
group.add(new AnAction(scenario.getPresentableText(), scenario.getLocationString(), isChecked ? AllIcons.Actions.Checked : null) {
@Override
public void actionPerformed(AnActionEvent e) {
//Do something here
}
});
}
final ActionPopupMenu popupMenu =
((ActionManagerImpl) ActionManager.getInstance())
.createActionPopupMenu(ToolWindowContentUi.POPUP_PLACE, group, new MenuItemPresentationFactory(true));
//Show menu here

The code above works just fine, the actions are displayed as menu items and selecting them triggers the right actions, but I don't see any icons being displayed.

 

0
3 comments

Does it work when you pass in false in MenuItemPresentationFactory() ctor?

0
Avatar
Permanently deleted user

Ah, bingo, that was it! Thank you!

 

0

Great, see com.intellij.openapi.actionSystem.impl.MenuItemPresentationFactory#processPresentation condition

0

Please sign in to leave a comment.