I used to use a simple SKILL program that reads in the default allegro.men file from each base release, performs my company customizations, and then reads out the modified file. It worked pretty well and just needed tweaking after each base release was pushed.
With the new release, err, cadence starting with 16.6, the menus are changing fast. When the axlUIMenu* functions were first released they seemed to be borked pretty hard, but I hope they're mature since that seems to be the only reasonable way to go to. (Admittedly, it is far more powerful and I'm anxious to get this working for future maintainability.)
OK, to get started so I wrote a regular prodcedure and called it in allegro.ilint using axlUIMenuRegister commands. Easy as pie. I can get new menu items to pop in above (and only above!) existing menu items.
For example, note that axlUIMenuRegister("save_as" '((Write "write"))) adds "Write" before "Save As...".
However, I want to add some items before a separator. I don't see any way to uniquely identify a separator in a particular menu, so what to do? Well, since axlUIMenuFind() seems to return an integer, maybe I can just call that and then increment the return value. Nope. Wrapping wrapping axlUIMenuFind() with add1() makes the resulting axlUIMenuInsert() do nothing.
I see that axlUIMenuInsert(axlUIMenuFind(nil "save_as") "Write" "write") also adds "Write" before "Save As..." if I use axlTrigger() to modify the menu. This also gives me the power to delete menu items, which was easy enough to get working. But I still can't figure out how to add a new item before a menu separator. To take the above example to the next level, how can I add "Write" *after* "Save As..."? There must be a way, right?
I have raised this with Cadence so, hopefully, we will see some additional functionality soon. In the meantime here are a couple of routines that might help:
defun( DE_UIMenuChangeDisplay (cmdStr, displayStr, "tt")
result = list(nil, sprintf(nil, "Menu item '%s' not found.", cmdStr))
menuId = axlUIMenuFind(nil, cmdStr)
result = list(nil, sprintf(nil, "Menu item '%s' not deleted.", cmdStr))
result = list(nil, sprintf(nil, "Menu insert command failed for '%s'.", cmdStr))
axlUIMenuInsert(menuId, displayStr, cmdStr)
result = list(t, sprintf(nil, "Menu display change for '%s' succeeded.", cmdStr))
defun( DE_UIMenuInsertBefore (curCmdStr, cmdStr, displayStr, "ttt")
result = list(nil, sprintf(nil, "Menu item '%s' not found.", curCmdStr))
menuId = axlUIMenuFind(nil, curCmdStr)
result = list(t, sprintf(nil, "Menu insertion for '%s' succeeded.", cmdStr))
defun( DE_UIMenuInsertAfter (curCmdStr, curDisplayStr, cmdStr, displayStr, "tttt")
axlUIMenuInsert(menuId, "temp", "temp")
result = list(nil, "Menu delete command failed.")
axlUIMenuInsert(menuId, curDisplayStr, curCmdStr)
menuId = axlUIMenuFind(nil, "temp")
Hi Dave. Thank you! The last function does what it says on the tin. :)
Here's some items I noted after using the last function you posted above:
1. Typing in both the new and old command name along with each command's displayed name is a lot of work. I don't see another solution, though...
2. It doesn't work for lists, which makes creating a sub-menu just above a separator difficult or impossible.
3. By deleting and re-creating the menu item, the hot key (when pressing Alt in the menu stack) must also be included in the argument. But it's quite painful to do anything but have the user manually handle this.
And more thoughts, which are intended to point out the limitations present in the current menu modification functions provided by Cadence (and to which you partially addressed with your code):
4. What if I wanted to add a new command around an existing submenu? I only see a way to target inserting menus above a unique command (or below it, with Dave's code). For example, how could I insert a new menu item above or below Setup > Application Mode?
5. How can I add control over a menu item based on license tier with these SKILL functions? I could do that when I wrote my own menu file, but I don't see how to do that here. I don't need to do it now, but I don't see how it's currently possible.
6. How can a new menu be added to the very end (right side) of the menu strip? Solution ID 11272754 is interesting, but I don't see how it can be done with SKILL. Combining it with page 529 of algroskill.pdf from v16.6, one might think axlUIMenuInsert(axlUIMenuFind(nil -1) 'popup axlVersion('fullVersion)) could work. But it doesn't. The SPB version is pasted to the left of the Help menu, not the right.
Also, if someone wants to move this thread to the PCB SKILL forum it would be great. I started out involving SKILL, although menu modification is portrayed as being easy and mainstream, but it's moved squarely into the realm (abyss?) of SKILL.