Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[pde-dev] Diasabling Menuitems by code

Hi all,

cann someone exlain me how to get a reference to a menuitem by code to enable/disable it.

Problem is when i want to disable a single menu item e.g. File -> Save with following code i can only disable
the whole menu instead of single menuitems.

I tried to achieve this with following code:

        Menu menuBar = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                .getShell().getMenuBar();

        MenuItem [] items = menuBar.getItems();
        items[0].setEnabled(false);


With this code i can disable the file menu.


        MenuItem fileMenuItems [] =  items[0].getMenu().getItems();

when i add this line fileMenuItems are null after execution.

Can someone help me with this problem?

Sven
       



Rundum-Schutz für den PC - Windows Live OneCare: 90 Tage kostenlos!

Back to the top