8 Replies Latest reply on Nov 15, 2014 1:24 PM by syswizardx

    msgBox implementation needs help

    syswizardx

      I am trying to implement a generic message box that I can pass to execDialog.

      However, I am getting a syntax error when I attempt to put in static text for the message portion.

      Also, if I create a new Msgbox, how do I override the name and msg values....like this ????

       

      var newbox = new (Msgbox)

      newbox.name = "new title";

      newbox.msg = "this is the mesage:

       

       

      var Msgbox = {

        result: "cancel",

        DoDialog: function() {

          return app.execDialog(this);

        },

        initialize: function(dialog) {

          var dlgInit = {};

          dialog.load(dlgInit);

        },

        commit: function(dialog) {

          var oRslt = dialog.store();

        },

        "But1": function(dialog) {

          var answer = false;

          dialog.end()

        },

        description: {

          name: "This is the Title Line",

          elements: [{

            type: "view",

            elements: [{

              type: "view"},

              {item_id: "msg",

               name: "text message goes here",

               type: "static_text"},

              align_children: "align_row",

              elements: [{

                type: "ok",

                ok_name: "ok",

              }, {

                type: "button",

                item_id: "But1",

                name: "Cancel",

              }, ]

            }, ]

          }, ]

        }

      };

        • 1. Re: msgBox implementation needs help
          gkaiseril MVP & Adobe Community Professional

          There are 41 lines of code, each with a possible syntax error. Could you please post the exact message, since the error messages shown in the JavaScript console include a n approximate line number and a message about the type of error.

           

          I get the following error message:

           

          SyntaxError: unterminated string literal

          3:Console:Exec

          undefined

          • 2. Re: msgBox implementation needs help
            try67 MVP & Adobe Community Professional

            You're missing the closing double-quotes in line #3.

            Also, if you're trying to inject a dynamic string into the text of your dialog you should probably know it's not possible to do it, at least not like this.

            The only way I know of is to create the entire dialog object as a literal string and then execute it using the eval method, which is very very tricky.

            • 3. Re: msgBox implementation needs help
              syswizardx Level 1

              Thanks guys....that was stupid of me.....lack of sleep does funny things to me.

               

              I find it hard to believe I cannot make the message line and the title line dynamic....changeable after instantiating a new box.

               

              I was trying to follow this example:

               

              var TestDlg1 =
              {
                   description:
                   {
                       name: "My Test Dialog",
                       elements:
                       [
                          {
                             type: "view",
                             elements:
                             [
                                {
                                   item_id: "sta1",
                                   name: "Check the box",
                                   type: "static_text",
                                },
                                {
                                   item_id: "Chk1",
                                   name: "Check Box",
                                   type: "check_box",
                                }
                             ]
                          },
                          {
                             type: "ok_cancel",
                          },
                        ]
                     }
              };

              • 4. Re: msgBox implementation needs help
                syswizardx Level 1

                OK Guys, I finally figured this out - with one problem:

                The users can close the dialog without hitting a button by hitting the Close "X" in the right corner.

                 

                1) Is there an execDialog property to remove the X ?

                 

                2) How can I use the Destroy method to trap the dialog and prevent closing it. Is it possible ?

                • 5. Re: msgBox implementation needs help
                  try67 MVP & Adobe Community Professional

                  Were you able to insert a dynamic text into the dialog?

                  • 6. Re: msgBox implementation needs help
                    syswizardx Level 1

                    You bet. Very simple in fact. Gotta know your javascript object model however.

                     

                    Now the big problem is:

                    regular buttons do not fire their callbacks.

                    OK/Cancel buttons: no problem...they work with one fatal flaw.....the user can "X" close-out of the form without a response being returned.

                    • 7. Re: msgBox implementation needs help
                      try67 MVP & Adobe Community Professional

                      Can you post an example?

                       

                      Clicking the "X" button will also trigger the "destroy" event.

                      • 8. Re: msgBox implementation needs help
                        syswizardx Level 1

                        I'll do that later....I'm on deadline right now. I was able to eliminate the "X" button using custom buttons instead of the ok_cancel.

                         

                        A couple of observations:

                        1) only 4 char string return value for dialog.end method ?

                        TOTALLY PATHETIC. Should allow "Variants"...any type to be returned

                         

                        2) no Visible property ?

                        Again, TOTALLY PATHETIC. Very basic property that provides a lot of flexibility (which this API does NOT have)

                         

                        3) no Property setting to eliminate the "X" close button.

                        Unbelievable. That puts this API actually BEHIND VBA which is going on 15+ years.

                         

                        All in all, I am fast coming to the conclusion this was poorly designed (execDialog).

                        Couple that with the pathetic debugger and editor...and well, I have no respect for Acrobat technical management.....none.

                        So poorly was this done, one could only conclude: there's a really hot place in you-know-where reserved for the architects of execDialog.