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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Add Menu to ProductView Context Menu

ptc-830759
1-Visitor

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.

0 REPLIES 0
Announcements


Top Tags