There are a couple of ways to approach this, you can either define menu items via a menus file, i.e. the layEdit.menus in this case, which would reside in your ./menus/ or ~/menus directory, or you can create the menus and add them via SKILL. Here's a brief example of the bits that you might need for that approach:
procedure(AmitAddMenu(args) let( ((win args->window) item1 item2 menu) ;; create a couple of menu items item1 = hiCreateMenuItem( ?name 'item1 ?itemText "My First Item" ?callback "AmitFunctionOne()" ) item2 = hiCreateMenuItem( ?name 'item2 ?itemText "My Second Item" ?callback "AmitFunctionTwo()" ) ;; create a menu that includes the menu items menu = hiCreatePulldownMenu('AmitMenu "Amit Menu" list(item1 item2)) ;; insert this menu as the last menu hiInsertBannerMenu(win menu length(hiGetBannerMenus(win)) );let); procedure;; create a user postinstall trigger that automatically adds the menudeRegUserTriggers("maskLayout" nil nil 'AmitAddMenu)
You might need to add code to check if the menu is already present, but hopefully this framework gives you an idea of how to do it.
In reply to skillUser:
I can't really read your posted code, but it looks like you missed off the all-important deRegUserTriggers() command? This is the part that automatically runs your code, triggered by the action of opening a layout - hence, you may only need to do this once if the menu is global across all layout windows. When you open a layout window the code is triggered and it adds the menu. Job done!
Am I missing something else?
In reply to Amit Biswas:
the error message appears to be self explanatory: My_Custom_Menu will be supplied with one argument that is a disembodied property list ("dpl" for short) but it was defined to accept no arguments:
*Error* My_Custom_Menu: too many arguments (0 expected, 1 given) - ...
The trigger will automatically supply the dpl to the function, this is why the function needs to accept at least one argument. See my example where I have "args" for this argument, and then this is used to obtain the window id (this is the correct way to do it anyway, since hiGetCurrentWindow() can actually pick up the "What's New" window, for example).
Also, which version are you using? I'd guess at 9502/4.3.4 given the "dag" prefixed functions, but it is possible that these are just customizations...
Try again and let us know how things turn out.
I should point out that the way that Lawrence suggested doing this is the wrong way to add a banner menu (sorry Lawrence). Adding a pulldown banner menu in a post install trigger is likely to cause trouble (I've seen this happen numerous times), and since there is a userMenuTrigger available (this is the third argument to deRegUserTriggers). In fact it makes it simpler, because all your function has to do is return a list of pulldown menus to add, and does not need to worry itself with inserting them in the banner - that is done by the Design Editor infrastructure. So it would be something like:
procedure(AmitAddMenu(_args) let( (item1 item2) ;; create a couple of menu items item1 = hiCreateMenuItem( ?name 'item1 ?itemText "My First Item" ?callback "AmitFunctionOne()" ) item2 = hiCreateMenuItem( ?name 'item2 ?itemText "My Second Item" ?callback "AmitFunctionTwo()" ) ;; create a menu that includes the menu items and return a list of the ;; pulldown menus list(hiCreatePulldownMenu('AmitMenu "Amit Menu" list(item1 item2))) );let); procedure;; create a userMenuTrigger trigger that automatically adds the menudeRegUserTriggers("maskLayout" nil 'AmitAddMenu)
Note this is untested - and in practice you would add code to avoid redefining the pulldown menu each time (e.g. unless(boundp('AmitMenu) ...) but hopefully you get the principle.
In reply to Andrew Beckett:
if i want to add menus in virtuoso analog design environment, what is the first argument in the deRegUserTriggers function? can anybody give a name list of ADE and layout ect,
In reply to imagesensor123:
In reply to Amit Biswas:
yes, we can do that and i am sure "maskLayout" can be replaced by "schematic", and now , i want to add a menu in analog environment , so which argument should i use?
For ADE, you could use "analogArtist-schematic", however this will only work when you start ADE from the schematic. If you open it from the CIW, or by loading a state directly (e.g. from the library manager), then it will not trigger. The issue is that ADE is not really an editor of a view in the same sense as maskLayout or schematics, and so the Design Editor (i.e. de) functionality doesn't come into play.
The right way to do ADE customization is to use menus files. Here's one way:
The other way to do it might be to use the sessInitTrigFunc cdsenv setting:
This sessInitTrigFunc was added in IC5141 in 220.127.116.110.5.124 and is also in IC612 onwards (it was added in an IC611 hotfix, strictly speaking), in September 2008.
why i can't login the link you writed?
You'll need a Cadence Online Support account (this requires you to be a customer with a maintenance contract). You can register via http://support.cadence.com - you'd need access to your License server hostid to do it (so that we can identify which customer you are). If you're at a European university and accessing your software via Europractice, you'd need to contact Europractice (I believe they have the means to create "light" accounts which allow read access to solutions etc, but not submit service requests - you have to do that via Europractice).
thanks, have a good day!