cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Add Menu to ProductView Context Menu

Highlighted
Level 1

Add Menu to ProductView Context Menu

I'm using the ProductView API M030 - In the documentation of M030 the description of how to implement a menu item in the ProductView context menu is missing. So here is the how to:

In your actor you have to add a method to hande the menu item:

public void manageMenuItemEvent (MenuItemEvent ev )
    {
        ManageObject (ev.GetMenuItemIf());
    }

I have an class where i put all the basic function of the api (pvStdManager). There i have a method that adds the menu item to the world object and call the prior method in the actor:

public static void addMenu (MenuItemEvent menuEvent)
    {
        try {

            //manage the menu item in your actor
            stdActor.manageMenuItemEvent(menuEvent);

            //add your menu item to the world object
            theWorld.AddMenuItem(menuEvent.GetMenuItemIf());
        } catch (Exception ex) {
            Logger.getLogger(pvStdManager.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

The method is staic so you can acess it from everywere in your code. There you have to create a class (i have made a subclass) that extends com.ptc.pview.pvkapp.MenuItemEvent:

       private class ProeMenuItemEvent extends com.ptc.pview.pvkapp.MenuItemEvent {

        ProeMenuItemEvent() {
            super("Enter Menu Text here", 0);
        }

        public void OnDoCommand() {
            // do something
        }
    }

I like the Idea of Conext menus so i am happy to use that function.