Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Adding Menus with JLink

newton126

New member
I have been successful so far in adding a custom menu to the main toolbar and adding a button to that menu. What I am struggling with is how to add a custom sub-menu to my existing menu.


Here is the code I have:
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">


try {
curSession = pfcGlobal.GetProESession();


curSession.UIAddMenu("TopMenu1", "Help", "test.txt", null);

UICommand cmd = curSession.UICreateCommand("JL.HelpMenuApp",new MenuButtonListener());

curSession.UIAddButton(cmd, "TopMenu1", null, "SubButton1", "SubButton1Help", "test.txt");

curSession.UIAddMenu("SubMenu1", "SubButton1", "test.txt", "TopMenu1");
}</BLOCKQUOTE>
I'm basically trying to add a new menu called "SubMenu1" to main menu "TopMenu1". It compiles OK but when I start Pro/E, I only get TopMenu1 with SubButton1. SubMenu1 does not appear.
Any help is much appreciated.
 
Try this:

curSession.UIAddMenu("TopMenu1", "Help", "test.txt", null);
curSession.UIAddMenu("SubMenu1", "", "test.txt", "TopMenu1");

Then add your buttons afterward.

I have a top-level menu and 4 sub-menus, each with their own buttons. I add all the menus first, then the buttons later. The sub-menus appear at the bottom of my main menu.

Hope that helps.



Edited by: DanWolf
 
Thanks for the suggestion but it did not work. Same result.


I can add SubMenu1 to the top Pro/E menu and to other menus (like File or Windows). It just won't add it to TopMenu1.
 
I figured it out. You have to have a button added to the submenu in order for it to appear. I thought the menu would appear and I could add a button later.
 

Sponsor

Back
Top