Popup menu on custom view in Eclipse Plug-In (Kepler)

后端 未结 1 813
终归单人心
终归单人心 2021-01-16 04:53

Is there a way to provide a static popup menu for a custom view in Eclipse Kepler? Creating a dynamic one is easy, but I would like to be able to define the commands in the

1条回答
  •  一生所求
    2021-01-16 05:24

    In your view part set up the context menu like this:

    MenuManager contextMenu = new MenuManager();
    contextMenu.setRemoveAllWhenShown(true);
    
    Control control = viewer.getControl();
    Menu menu = contextMenu.createContextMenu(control);
    control.setMenu(menu);
    
    getSite().registerContextMenu(contextMenu, viewer);
    

    The registerContextMenu call makes the menu available to the org.eclipse.ui.menus extension point so you can define menu items like this:

      
          
             ... you menu items ...
    

    0 讨论(0)
提交回复
热议问题