• 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. How to write the code - menuItemCallbacks of hiCreateSimpleMenu...

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 143
  • Views 2506
  • 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

How to write the code - menuItemCallbacks of hiCreateSimpleMenu ?

Charley Chen
Charley Chen over 12 years ago

 

 Dear All ,

I want to create a simple menu(hiCreateSimleMenu) ,

which arg l_menuItems  are fixed  , //A -> B -> C

each  A -> B -> C has it shape id // db:1111 db:2222 db:3333

How to let arg l_menuItemCallbacks follows  the l_menuItems correspondence ?

e.g. 

if   choose A , it will select  db:1111

if   choose B , it will select  db:2222

if   choose C , it will select  db:3333

 

hiCreateSimpleMenu( 'test  "QQ"  list("A" "B" "C")  ????)

I don't know how to write ???  code  , How to do it ?

 

Thank you,

Charley

  • Cancel
  • skillUser
    skillUser over 12 years ago

     Hi Charley,

    If I have understood your request correctly, it would be something like the following, assuming that the variables "A", "B" etc. contain the database ids of the appropriate instances:

    
    
    items = list(A B C)
    hiDisplayMenu(
      hiCreateSimpleMenu('CCFinstSelectMenu
        "Select Instances"
        foreach(mapcar item items item~>name)
        foreach(mapcar obj items
          sprintf(nil "geSelectFig(dbFindAnyInstByName(geGetEditCellView() %L))"
            obj~>name)
        )
      )
    )
    
    

    I have attached an image of what this might look like - hopefully this is the sort of thing that you were looking for? (If you want "A", "B" etc. in the menu rather than the instance name, simply put the following as the first list passed to the menu function: list("A" "B" "C"), as in your example.

    Best regards,

    Lawrence.

    • SelectInstances.png
    • View
    • Hide
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Charley Chen
    Charley Chen over 12 years ago

     Hi Lawrence ,

    Yes , You totally understanded my request.

    In fact ,  items maybe contains insts & shapes , so the code needs to add something ,

    e.g.  determin  whether is shape , if shape  select the shape , if instance , select the instance.

    But I don't know how to write . Could you help me ?

     foreach(mapcar obj items
          sprintf(nil "geSelectFig(dbFindAnyInstByName(geGetEditCellView() %L))"
            obj~>name)
        )

     

    Thank you,
    Charley 

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 12 years ago

    Hi Charley,

    Here is an attempt at what you are asking for - it may not work under all circumstances, I've arbitrarily picked the center of the objects' bounding box, but if there is an overlapping object this might pick the wrong object when performing the selection.

    
    hiDisplayMenu(
      hiCreateSimpleMenu(
        'CCFinstSelectMenu
        "Select Instances"
        '("A" "B" "C" "D" "E")
        foreach(mapcar obj items 
          case(obj~>objType
            ("inst"
              sprintf(nil
                "geSelectFig(dbFindAnyInstByName(geGetEditCellView() %L))"
                obj~>name
              )
            )
            (t
              sprintf(nil
                "geSelectFig(gePointToFig(hiGetCurrentWindow() t %g:%g))"
                car(centerBox(obj~>bBox)) cadr(centerBox(obj~>bBox))
              )
            )
          ); case
        ); foreach
      ); hiCreateSimpleMenu
    ); hiDisplayMenu
    

    I tested this very briefly and it seems as though it should work.

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Charley Chen
    Charley Chen over 12 years ago

     Hi Lawrence , 

    Thank you , But when has many shapes overlap , it won't work.

    (1)Can I write arg l_menuItemCallbacks as a function call ?

    foreach(mapcar obj items
            sprintf(nil "TEST(obj)") //it wont work
    );foreach 
    procedure( TEST(obj)
    printf("%L" obj) 
    );pro 
     
    (2)
    If select "A" ,  it has its dbId , How to pass its dbId 
    If select "B" ,  it has its dbId , How to pass its dbId  
    ...
     
    Thank you,
    Charley 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    Fundamentally the limitation is that the callback has to be a string, and you can't represent a db object as a string (well, you can, but you can't then use that to locate the db object again, so that's not terribly helpful). It's not obvious how you are indicating to the user what the menu items are and how that relates to the db object underneath, but one solution would be to do this when you build the simple menu:

    MyGlobalItemTable=makeTable('dbLookup nil)
    foreach(mapcar obj items
        sprintf(itemText "%L" obj)
        MyGlobalItemTable[itemText]=obj
        sprintf(nil "TEST(\"%L\")" obj) ; generate callback
    );foreach

    then in your callback function, you can do:

    procedure(TEST(objString)
      realObj=MyGlobalItemTable[objString]
      ... do whatever you want here
    )

    Whatever you do, however, don't hang onto the contents of the global table for too long -  because the database ids might get invalid or recycled (e.g. if objects are deleted, or the containing cellView is purged). For the duration of a popup menu though, it's probably fine though.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Charley Chen
    Charley Chen over 12 years ago

     Andrew,

     Thank you for help , I will try it.

    Charley

     

    • 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