• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Menu creation in Explorer

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 142
  • Views 5400
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Menu creation in Explorer

kkdesbois
kkdesbois over 1 year ago

Hello,

I'd like to a submenu to the Menu Setup in Explorer.
I usually use this kind of code to do it.

(deRegUserTriggers "explorer" nil nil 'customMenusInExplorer)

(defun customMenusInExplorer (largs)
(let (wid session s_setupMenu submenu1)
(setq wid (getq largs window))
(setq session (getq wid sevSession))
(setq s_setupMenu
   (car (setof x (hiGetBannerMenus wid) (pcreMatchp "Set[&]?up" (getq (eval x) _menuTitle)))))
(setq submenu1
   (hiCreatePulldownMenu 'submenu1
                                          "submenu1"
                                          (list (hiCreateMenuItem ?name 'subsubmenu1
                                                                                ?itemText "subsubmenu1"
                                                                                ?callback (sprintf nil "(CBsubsubmenu1 '%L)" ,session))
                                                 (hiCreateMenuItem ?name 'subsubmenu2
                                                                                 ?itemText "subsubmenu2"
                                                                                 ?callback (sprintf nil "(CBsubsubmenu2'%L)" ,session)))))
(hiAddMenuItem (symeval s_setupMenu) (hiCreateSliderMenuItem ?name 'sliderCustomMenu ?itemText "Custom Menu" ?subMenu submenu1))
) ; let
) ; defun

I've bee told that getting the session like I do may be source of trouble (several Explorer opened,...)

Do you confirm? If so, is there a safer way to do it?

Laurent.

  • Cancel
Parents
  • AurelBuche
    AurelBuche over 1 year ago

    Salut Laurent,

    I think that's quite OK as you are setting the session variable but you don't reference it in the rest of the code...

    You are fetching the window from the DPL that is passed as your trigger's argument so I guess you will always get the one you want.

    But the way you fetch the banner menu might cause trouble : 

    If you have another banner menu called Setup your submenu might be placed at the wrong position

    Also you can always replace (car (setof ...)) in your codes by (car (exists ...)) to improve runtime and avoid completely parsing lists when you can stop earlier.

    You can also use (lsprintf ...) instead of (sprintf nil ...) but this is just syntactic sugar

    And for safety, in case your trigger is called two times in the same window, you might add a check to make sure the submenu does not exists already

    (although it might be ok because your submenu name is fixed, but it should print a warning)

    Hope this helps,

    Cheers

    Aurélien

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • AurelBuche
    AurelBuche over 1 year ago

    Salut Laurent,

    I think that's quite OK as you are setting the session variable but you don't reference it in the rest of the code...

    You are fetching the window from the DPL that is passed as your trigger's argument so I guess you will always get the one you want.

    But the way you fetch the banner menu might cause trouble : 

    If you have another banner menu called Setup your submenu might be placed at the wrong position

    Also you can always replace (car (setof ...)) in your codes by (car (exists ...)) to improve runtime and avoid completely parsing lists when you can stop earlier.

    You can also use (lsprintf ...) instead of (sprintf nil ...) but this is just syntactic sugar

    And for safety, in case your trigger is called two times in the same window, you might add a check to make sure the submenu does not exists already

    (although it might be ok because your submenu name is fixed, but it should print a warning)

    Hope this helps,

    Cheers

    Aurélien

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • kkdesbois
    kkdesbois over 1 year ago in reply to AurelBuche

    Thanks Aurélien for the tricks ;)

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to kkdesbois

    This is the kind of check you should add around adding the menu. Normally you add menus in the userMenuTrigger  but in this case it's modifying an existing menu, so you really have to do that in the userPostInstallTrigger. I don't think the trigger gets called more than once in ADE (you don't have the issue with descending/ascending hierarchy), and also the pulldown menus are unique per Explorer window, but it's good practice to add the check around the code.

    (deRegUserTriggers "explorer" nil nil 'customMenusInExplorer)
    
    (defun customMenusInExplorer (largs)
      (let (wid session s_setupMenu submenu1)
        (setq wid (getq largs window))
        (setq session (getq wid sevSession))
        (setq s_setupMenu
    	  (car (setof x (hiGetBannerMenus wid) (pcreMatchp "Set[&]?up" (getq (eval x) _menuTitle)))))
        (unless (getq (symeval s_setupMenu) sliderCustomMenu)
          (setq submenu1
    	    (hiCreatePulldownMenu 'submenu1
    				  "submenu1"
    				  (list (hiCreateMenuItem ?name 'subsubmenu1
    							  ?itemText "subsubmenu1"
    							  ?callback (sprintf nil "(CBsubsubmenu1 '%L)" ,session))
    					(hiCreateMenuItem ?name 'subsubmenu2
    							  ?itemText "subsubmenu2"
    							  ?callback (sprintf nil "(CBsubsubmenu2'%L)" ,session)))))
          (hiAddMenuItem (symeval s_setupMenu) (hiCreateSliderMenuItem ?name 'sliderCustomMenu ?itemText "Custom Menu" ?subMenu submenu1))
          )
        ) ; let
      ) ; defun

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • kkdesbois
    kkdesbois over 1 year ago in reply to Andrew Beckett

    thank you

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information