• 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. After creating dockable window containing a form, how to...

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 143
  • Views 7720
  • 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

After creating dockable window containing a form, how to locate and delete in order to recreate the dockable window and form

blankman
blankman over 1 year ago

Hi,

I am trying to create a dockable window in layout window containing a form, however I am running into the issue after creating the window/form, that when the "x" top right of the dockable window is pressed, it doesn't actually close the window, but hides it. To be able to unhide the window after it is hidden, I need to re-create the window&form by again calling the procedure, however in order for this to work, I must first locate and delete the originally created dockable window and form. This is where I have the question. Does anyone know how to find and delete the original dockable window and form? Below is an outline of the code I am using to create the window.

Thanks and regards,

Brian.

-------------------------------------------------

After defining a form within a procedure: "dockForm()"


procedure(dockFormDisplay()

myForm1= dockForm()

myDockW=hiCreateDockWindow( ?appType "text" ?widgetType "form" ?title "Form" ?form myForm1)

hiDockWindow( ?window myDockW ?session hiGetCurrentWindow()->sessionWindow ?side 'left )

)

  • Cancel
Parents
  • AurelBuche
    AurelBuche over 1 year ago

    Hi Brian,

    When you close a dockable window it actually unmaps it.
    (If you hover on the 'x' button, you should see a tooltip saying 'hide' and not 'close')

    To close the window instead of unmapping it, the simplest thing is to add a visibilityProc.

    procedure( my_app_create_form()
      "Create and return 'My App' form"
      hiCreateLayoutForm(
        gensym( 'my_app_form)
        "My App"
        hiCreateFormLayout( 'main_layout
          ?items list( hiCreateOutputStringField( ?name 'text1 ?prompt "Test Form\n"))
        )
      )
    )
    
    procedure( my_app_close_dwin(dwin mapped)
      "Close DWIN if MAPPED is nil, this is meant to be used as `hiCreateDockWindow' ?visibilityProc"
      ;; `hiEnqueueCmd' has to be closed because it is not possible to close directly a window
      ;; inside the visibilityProc
      my_app.dwin = dwin
      unless( mapped hiEnqueueCmd( "hiCloseWindow(my_app.dwin)" ))
      )
    
    procedure( my_app_create_dwin()
      "Create and return 'My App' dockable window"
      hiCreateDockWindow(
        ?appType        "text"
        ?widgetType     "form"
        ?title          "My App"
        ?form           my_app_create_form()
        ?visibilityProc 'my_app_close_dwin
      )
    )
    
    procedure( my_app_map_dwin()
      "Map 'My App' dockable window into the current session window"
      hiDockWindow(
        ?window  my_app_create_dwin()
        ?session hiGetSessionWindow( hiGetCurrentWindow())
        ?side    'left
      )
    )

    Also, if you allow me to give you some advice:

    1. You should use `hiCreateLayoutForm' and associated functions (they are way smarter than `hiCreateAppForm'):
    `hiCreateFormLayout', `hiCreateVerticalBoxLayout', `hiCreateHorizontalBoxLayout', ...

    2. You should give more explicit names to your functions, the names you use (testForm, callForm, ...)
    are not meaningful and quite confusing

    3. Be careful with global variables (even more if you are using generic names) you will encounter unexpected issues
    If you modify those variables in two different scripts, which is very probable with objects named myForm, myForm1,
    myDockW, ...
    If you need variables to be shared between your functions, a good solution is to give a generic name to your script
    and use the '.' operator

    my_app.form = hiCreateLayoutForm(...)
    my_app.dwin = hiCreateDockWindow(...)

    4. When you share your code, please avoid sending it piece by piece.
    It is quite complicated to ensure the behavior is the same if the whole script is different.

    Hope this helps,

    Aurélien

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

    If you want to display only one dockable window, you can modify the code like this : 

    procedure( my_app_create_form()
      "Create and return 'My App' form"
      hiCreateLayoutForm(
        gensym( 'my_app_form)
        "My App"
        hiCreateFormLayout( 'main_layout
          ?items list( hiCreateOutputStringField( ?name 'text1 ?prompt "Test Form\n"))
        )
      )
    )
    
    procedure( my_app_close_dwin()
      "Make sure my_app.dwin is closed"
      when( my_app.dwin
        hiCloseWindow(my_app.dwin)
        my_app.dwin=nil
      )
    )
    
    procedure( my_app_close_dwin_cb(_dwin mapped)
      "`my_app_close_dwin' wrapper to close dockable window when unmapped,
    close my_app.dwin when MAPPED is nil.
     This is meant to be used as `hiCreateDockWindow' ?visibilityProc"
      ;; `hiEnqueueCmd' has to be closed because it is not possible to close directly a
      ;; window inside the visibilityProc
      unless( mapped
        hiEnqueueCmd( "my_app_close_dwin()" )
      )
    )
    
    procedure( my_app_create_dwin()
      "Create and return 'My App' dockable window"
      ;; Always store newly created dockable windows in global variable
      ;; Also make sure previously defined window is closed
      my_app_close_dwin()
      my_app.dwin = hiCreateDockWindow(
        ?appType        "text"
        ?widgetType     "form"
        ?title          "My App"
        ?form           my_app_create_form()
        ?visibilityProc 'my_app_close_dwin_cb
      )
    )
    
    procedure( my_app_map_dwin()
      "Map 'My App' dockable window into the current session window"
      hiDockWindow(
        ?window  my_app_create_dwin()
        ?session hiGetSessionWindow( hiGetCurrentWindow())
        ?side    'left
      )
    )
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to AurelBuche

    Thanks AurelBuche, this is very helpful. This allows me to create a dock window in one session window. However, when the dock window is then created in a second session window it deletes the dock window from the first session window. Is there a way to have multiple dock windows open at any one time; ie multiple session windows, and within each session window, the dock window?

    Also, when having created the dock window in a session window, and then that session window is closed, I get the following error message when trying to recreate the dock window in a newly opened session window. Is there a means to address this so as to allow for the dock window to be again created in the newly opened session window?

    my_app_create_dwin()
    *Error* hiCloseWindow: Invalid window - window(invalid):663445024(destroyed)

    Thanks again for your help. All most appreciated,

    Brian

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

    Hi Brian,

    You can do that using several methods

    A simple one consists in storing the dockable window as a custom property of your window or session window

    Another one is done by creating a mapping table that will reference each dockable window using its associated window/session window

    Here is an example of the second solution:

    procedure( my_app_create_form()
      "Create and return 'My App' form"
      hiCreateLayoutForm(
        gensym( 'my_app_form)
        "My App"
        hiCreateFormLayout( 'main_layout
          ?items list( hiCreateOutputStringField( ?name 'text1 ?prompt "Test Form\n"))
        )
      )
    )
    
    procedure( my_app_close_dwin(swin)
      "Make sure dockable window in SWIN is closed"
      when( my_app.dwins_table[swin]
        hiCloseWindow(my_app.dwins_table[swin])
        remove( swin my_app.dwins_table )
      )
    )
    
    procedure( my_app_close_dwin_cb(dwin mapped)
      "`my_app_close_dwin' wrapper to close dockable window when unmapped,
    close my_app.dwin when MAPPED is nil.
     This is meant to be used as `hiCreateDockWindow' ?visibilityProc"
      ;; Find session window containing dwin
      let( ( (swin car( exists( swin my_app.dwins_table[?] my_app.dwins_table[swin]==dwin)))
           )
        unless( mapped
          ;; `hiEnqueueCmd' has to be closed because it is not possible to close directly a
          ;; window inside the visibilityProc
          ;; As the following expression is called in a string, we have to fetch session
          ;; window number and retrieve the window object using `swindow'
          hiEnqueueCmd( lsprintf( "my_app_close_dwin(swindow(%d))" cadr(parseString(lsprintf("%L" swin)))))
        )
      )
    )
    
    procedure( my_app_create_dwin(swin)
      "Create and return 'My App' dockable window"
      ;; Always store newly created dockable windows in global table
      ;; Also make sure previously defined window is closed
      unless( tablep( my_app.dwins_table )
        my_app.dwins_table = makeTable('dwins nil)
      )
      my_app_close_dwin(swin)
      my_app.dwins_table[swin] = hiCreateDockWindow(
        ?appType        "text"
        ?widgetType     "form"
        ?title          "My App"
        ?form           my_app_create_form()
        ?visibilityProc 'my_app_close_dwin_cb
      )
    )
    
    procedure( my_app_map_dwin()
      "Map 'My App' dockable window into the current session window"
      let( ( (swin hiGetSessionWindow( hiGetCurrentWindow()))
           )
        hiDockWindow(
          ?window  my_app_create_dwin(swin)
          ?session swin
          ?side    'left
        )
      )
    )

    Cheers,

    Aurélien

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • AurelBuche
    AurelBuche over 1 year ago in reply to blankman

    Hi Brian,

    You can do that using several methods

    A simple one consists in storing the dockable window as a custom property of your window or session window

    Another one is done by creating a mapping table that will reference each dockable window using its associated window/session window

    Here is an example of the second solution:

    procedure( my_app_create_form()
      "Create and return 'My App' form"
      hiCreateLayoutForm(
        gensym( 'my_app_form)
        "My App"
        hiCreateFormLayout( 'main_layout
          ?items list( hiCreateOutputStringField( ?name 'text1 ?prompt "Test Form\n"))
        )
      )
    )
    
    procedure( my_app_close_dwin(swin)
      "Make sure dockable window in SWIN is closed"
      when( my_app.dwins_table[swin]
        hiCloseWindow(my_app.dwins_table[swin])
        remove( swin my_app.dwins_table )
      )
    )
    
    procedure( my_app_close_dwin_cb(dwin mapped)
      "`my_app_close_dwin' wrapper to close dockable window when unmapped,
    close my_app.dwin when MAPPED is nil.
     This is meant to be used as `hiCreateDockWindow' ?visibilityProc"
      ;; Find session window containing dwin
      let( ( (swin car( exists( swin my_app.dwins_table[?] my_app.dwins_table[swin]==dwin)))
           )
        unless( mapped
          ;; `hiEnqueueCmd' has to be closed because it is not possible to close directly a
          ;; window inside the visibilityProc
          ;; As the following expression is called in a string, we have to fetch session
          ;; window number and retrieve the window object using `swindow'
          hiEnqueueCmd( lsprintf( "my_app_close_dwin(swindow(%d))" cadr(parseString(lsprintf("%L" swin)))))
        )
      )
    )
    
    procedure( my_app_create_dwin(swin)
      "Create and return 'My App' dockable window"
      ;; Always store newly created dockable windows in global table
      ;; Also make sure previously defined window is closed
      unless( tablep( my_app.dwins_table )
        my_app.dwins_table = makeTable('dwins nil)
      )
      my_app_close_dwin(swin)
      my_app.dwins_table[swin] = hiCreateDockWindow(
        ?appType        "text"
        ?widgetType     "form"
        ?title          "My App"
        ?form           my_app_create_form()
        ?visibilityProc 'my_app_close_dwin_cb
      )
    )
    
    procedure( my_app_map_dwin()
      "Map 'My App' dockable window into the current session window"
      let( ( (swin hiGetSessionWindow( hiGetCurrentWindow()))
           )
        hiDockWindow(
          ?window  my_app_create_dwin(swin)
          ?session swin
          ?side    'left
        )
      )
    )

    Cheers,

    Aurélien

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

    Thanks Aurélien, again very helpful and appreciated. Final question for now if you could also help with: is there a means that the dock window can be docked to the north of other windows that are already docked on that side of the screen? For instance, in my setup I have the Layer Palette docked to the left side of the screen, and I wish for the new dock window to dock to the north of the Layer Palette. Currently it docks to the south, ie at the end of the dock area, and could be easily missed. I have searched the hiDockWindow command, and it looks like ?index allows for this to be implemented, however, the value for which I have not been able to figure out in order to get it to dock to the north, or top, of the dock area. Thanks again, Brian.

    hiDockWindow(
          ?window  my_app_create_dwin(swin)
          ?session swin
          ?side    'left
    ?index -1 )

     

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

    Hi,

    Unfortunately my trials were not successful neither

    Maybe this feature is not working and a CCR should be filled 

    Cheers

    Aurélien

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

    Thanks again Aurélien, appreciate it. Kind regards, Brian.

    • 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