7 Replies Latest reply on Oct 25, 2012 9:03 AM by try67

    Custom Dialog not sizing correctly

    Milton123321

      Below is example code that is not working. I am trying to limit the size of the dialog box width. If I have static text that runs multiple lines, the dialog box resizes so that entire line of text is on one line on the box. How do I limit the size of the dialog box?

       

      var TestDlg1 =

      {

          description:

          {

              name: "My Test Dialog",

              char_width: 20, <----------------------- this line of code is suppose to limit the width of the Dialog box but it isnt.

              elements:

              [

                 {

                    type: "view",

                    elements:

                    [

                       {

                          item_id: "Item1",

                          name: "ChangeLog",

                          type: "static_text",

                       },

                       {

                          item_id: "Item2",

                          name: "dafssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssfdafdas fdafd afdasfdasfasfdasfdasfdasfdafdadfadafdasfdasfdafdasfdasfdasfdasfdasfdasfdasfdasvfdfafvadba f afasbfdavfdavfdasvfda fda vfda fdav fda rfadvf daf adfaf d",

                          type: "static_text",

                       },

                       {

                          item_id: "Chk1",

                          name: "Check Box",

                          type: "check_box",

                       }

                    ]

                 },

                 {

                    type: "ok_cancel",

                 },

               ]

            }

      }

        • 1. Re: Custom Dialog not sizing correctly
          Thom Parker Adobe Community Professional

          Objects in a custom JavaScript dialog have a minimum size, but not a maximum. All elements will expand to fit thier contents at the time the dialog is contructed. In this case your code is passing a very long string into a text box as the initial value, at the time the dialog is constructed. This causes the text box to expand horizontally to fit the text. Which causes it's parent container to expand, and so on.

           

          If you want it to be smaller you'll need to set the text after construction, in the "initialze" event.

           

          Like this:

           

          cTstTxt = "dafsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss sfdafdas fdafd afdasfdasfasfdasfdasfdasfdafdadfadafdasfdasfdafdasfdasfdasfdasfdasfda sfdasfdasvfdfafvadbaf afasbfdavfdavfdasvfda fda vfda fdav fda rfadvf daf adfaf d";

           

          var tstDlg1 = {

                                 initialize: function(dialog){ dialog.load({itm2:cTstTxt});},

                                 description:

                                 {...

           

          Also note that I shortened the "item_id" of your static text element. Item Ids are 4, and only 4, characters long.

           

           

          [ excessive self promotion links removed by admin ]

          • 2. Re: Custom Dialog not sizing correctly
            Milton123321 Level 1

            Thom,

             

            Thanks for the answer.

             

            A few final up questions.

             

            Lets say I had another line of text I wanted to insert, would I have to repeat the process you listed above. For example, below is code example:

             

            cTstTxt = "dafsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss sfdafdas fdafd afdasfdasfasfdasfdasfdasfdafdadfadafdasfdasfdafdasfdasfdasfdasfdasfda sfdasfdasvfdfafvadbaf afasbfdavfdavfdasvfda fda vfda fdav fda rfadvf daf adfaf d";

             

            cTstTxt1 = "Say Wutfdasfdasfdasfsafdasgreqthgfsgfdstrwetrsgfsdgfsdvbvcbhfsngsgfsdgfsgrw";

             

            var TestDlg1 =

            {

                initialize: function(dialog){ dialog.load({itm2:cTstTxt});},

                initialize: function(dialog){ dialog.load({itm3:cTstTxt1});},

                description:

                {

                    name: "My Test Dialog",

                    char_width: 20, <----------------------- this line of code is suppose to limit the width of the Dialog box but it isnt.

                    elements:

                    [

                       {

                          type: "view",

                          elements:

                          [

                             {

                                item_id: "Itm1",

                                name: "ChangeLog",

                                type: "static_text",

                             },

                             {

                                item_id: "Itm2",

                                name: "dafsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss sfdafdas fdafd afdasfdasfasfdasfdasfdasfdafdadfadafdasfdasfdafdasfdasfdasfdasfdasfda sfdasfdasvfdfafvadbaf afasbfdavfdavfdasvfda fda vfda fdav fda rfadvf daf adfaf d",

                                type: "static_text",

                             },

                             {

                                item_id: "Itm3",

                                name: "Say Wutfdasfdasfdasfsafdasgreqthgfsgfdstrwetrsgfsdgfsdvbvcbhfsngsgfsdgfsgrw",

                                type: "static_text",

                             },

                             {

                                item_id: "Chk1",

                                name: "Check Box",

                                type: "check_box",

                             }

                          ]

                       },

                       {

                          type: "ok_cancel",

                       },

                     ]

                  }

            }

            • 3. Re: Custom Dialog not sizing correctly
              Thom Parker Adobe Community Professional

              The answer is yes, all field initialization takes place in the initailize function. However, you can put all the values into the same function call.

               

              dialog.load({itm2:cTstTxt, itm3:cTstTxt1});

               

              You should remove the long name values from the static text definitions and add width and height parameters.

              • 4. Re: Custom Dialog not sizing correctly
                try67 MVP & Adobe Community Professional

                First of all, try using "width" property to limit the dialog's size, not "char_width".

                 

                In order to get a static_text field to show multiple lines the way you want it to, I found that the best option is to manually insert the line breaks ("\n") into your text, and then to make sure to set the field's height property accordingly. I use 15 points for each line, so if you have 3 lines, set the height to 45.

                • 5. Re: Custom Dialog not sizing correctly
                  Milton123321 Level 1

                  All,

                   

                  Thanks. Everything is working for the exception of Try67's response. I can get it to size correctly; however, it is now cutting off the text. Below is my code.

                   

                  cTstTxt = "Text1 is executing blah blah blah blah blah blah balah";

                  cTstTxt2 = "Text2 is executing blah blah blah blah blah blah balah";

                   

                  var TestDlg1 =

                  {

                      initialize: function(dialog){ dialog.load({itm1:cTstTxt, itm2:cTstTxt2});},

                      width: 300,

                      description:

                      {

                          name: "My Test Dialog",

                          elements:

                          [

                             {

                                type: "view",

                                elements:

                                [

                                   {

                                      item_id: "itm1",

                                      width: 300,

                                      type: "static_text",

                                   },

                                   {

                                      item_id: "itm2",

                                      width: 300,

                                      type: "static_text",

                                   }

                                ]

                             },

                             {

                                type: "ok_cancel",

                             },

                           ]

                        }

                  };

                  app.execDialog(TestDlg1);

                   

                  How do I break up the string to a new line with the /n line of code?

                   

                  I tried doing something like this:

                   

                  cTstTxt = "Text1 is executing blah blah blah blah /n blah blah balah";

                  cTstTxt2 = "Text2 is executing blah blah blah blah /n blah blah balah";

                   

                  but it does not work?

                  • 6. Re: Custom Dialog not sizing correctly
                    Thom Parker Adobe Community Professional

                    Text boxes default to a height of 1 line. So, set the height argument for the text box. Mr Try suggests 15 pts per line

                    • 7. Re: Custom Dialog not sizing correctly
                      try67 MVP & Adobe Community Professional

                      Mr Try was my father.... You can call me Gilad.