• 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 2507
  • 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
Parents
  • 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
Reply
  • 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
Children
No Data

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