8 Replies Latest reply on Mar 31, 2008 1:29 PM by (Daniel_Rodney)

    [JS] User Interface, Sizing Question

    Level 1
      I've have successfully used the minWidth option for textEditboxes and such, but I am trying to use it on a borderPanel and am not having any luck getting it to work. Here's some sample code that doesn't give an error, but also doesn't change the width of the borderPanel like I want (I want the panel to get wider...)

      myDialog = app.dialogs.add( {name:"My Dialog", canCancel:true} )
      
      with( myDialog ) {
      with( dialogColumns.add() )  {
        with( dialogRows.add() ) {
         with( borderPanels.add( {minWidth:800} )  ) {
          with( dialogColumns.add() ) {
           staticTexts.add( {staticLabel:"My Label:"} )
          }
          with( dialogColumns.add() ) {
           myTextEditBox = textEditboxes.add( {editContents:"initial text", minWidth:200} )
          }
         }
        }
      }
      }


      Any thoughts on how to get this to work? The reference says minWidth is an option on borderPanels, so what's the code? FYI, I am supporting CS2 and CS3 for the script I am writing. Thanks in advance!
      Dan
        • 1. Re: [JS] User Interface, Sizing Question
          Peter Kahrel Adobe Community Professional & MVP
          Daniel,

          Try minwidth (all lower case).

          Peter
          • 2. Re: [JS] User Interface, Sizing Question
            Level 1
            Lower case didn't work Peter, and in the Extended Toolkit's reference, it's minWidth with a capital W.

            Any other ideas? Is this even possible to size the Border Panel instead of the elements in it? I was just re-reading the help on it and it talks about boxes

            REFERENCE: ============
            BorderPanel.minWidth  
            Data Type: number
            The width of the control. For an editbox or combobox, specifies the minimum width of the box.
            • 3. Re: [JS] User Interface, Sizing Question
              Level 1
              Sizing depends on lots of things and there's lots of ways.

              For containers, use preferredSize to set height and width to values. It will set the height and width to that setting as a minimum. If the contents of the container need to be larger, it will make the container larger.

              If you want to have the container take up the available space (say there's another object not in the panel that makes the window wider/taller than the panel, you can set alignment = "fill";

              And you can always use the window.onShow event to do final tweaks. One of my favorites is to replace the name of the panel with a checkbox. The panel is enabled if the checkbox is checked. To do that, use the onShow method to move the checkbox to the correct location.

              Bob
              • 4. Re: [JS] User Interface, Sizing Question
                Level 1
                I think Bob is talking about ScriptUI while Daniel is trying to use InDesign dialogs.

                I'm not sure about the use of minWidth with Border Panels.

                Dave
                • 5. Re: [JS] User Interface, Sizing Question
                  Peter Kahrel Adobe Community Professional & MVP
                  Ugh. "minwidth" should indeed be "minWidth": I consult3ed some code I have and the values I used with "minwidth" happened to be the default, so I never realised that JS ignored the values I gave it. It has been less than helpful in not producing an error. And Dave is right: minWidth works only as a specified value in textEditboxes.

                  Peter
                  • 6. Re: [JS] User Interface, Sizing Question
                    Level 1
                    You are right Dave, I am using InDesign dialogs since I must support CS2.

                    It's confusing since the help lists minWidth under BorderPanels and no error is generated, but it doesn't work. So far I've been using empty spaces in static texts to "space" things out and make them look nice, but because of font differences between Mac and PC, only one platform looks perfect, while the other doesn't. I hoped that sizing the borderPanel directly would allow both platforms to have things line up perfectly.

                    Maybe it's a bug that it doesn't work? Maybe it's not meant to? I surely can't figure it out
                    • 7. Re: [JS] User Interface, Sizing Question
                      Level 1
                      JavaScript is a very open language. Need a new property for an object? Go ahead and create it by simply naming it.

                      Thus, BorderPanel.minwidth = 6 won't cause an error, it'll just add a new property and give it the value 6.

                      That minWidth doesn't work for BorderPanels is a surprise to me. It's a long time since I did such a dialog though.

                      Dave
                      • 8. Re: [JS] User Interface, Sizing Question
                        Level 1
                        That's cool Dave, I didn't realize you could define your own properties like that. That explains the lack of an error and I'll have to keep that in mind for the future. Now if only we could get this built in minWidth property to work :)