3 Replies Latest reply on Nov 26, 2017 10:46 AM by Thom Parker

    Restoring Button Position

    medos20

      Hi...

       

      i changed some buttons position using (.rect) function, so the buttons is controlled with other buttons to make them go up and down or right and left, are there anyway  to restore the original position for the buttons! that was created first time before moving them ? , thanks for help

        • 1. Re: Restoring Button Position
          Thom Parker Adobe Community Professional

          There are a couple of ways.

           

          1. Do not save the PDF. This way the buttons will always be at the position that was last saved.

           

          2. Save a list of original coordinates in a hidden field. Use JSON so it'll be easy to set and get.

           

          On this page ,  Free Sample PDF Files with scripts   , is a list of Sample PDF files, on it you'll find the "Swat the Fly" game, which is basically a button that moves around on the page. It does not solve your problem of saving the original position, its just an interesting sample of the process you've described.

          1 person found this helpful
          • 2. Re: Restoring Button Position
            medos20 Level 1

            Thank you,

             

            yes i set a hidden copy of the button in the original position and now its easy to restore it back to its position with JSON, thank you..

             

            i was using lingo (Macromedia Director Coding Language) and i always compare lingo with javascript, things much easier done in lingo and in lingo its easy to restore the rect becuase the software always remember the original rect or you can store it in Global Variable, i wonder if javascript for Acrobat have its own Global Variables or stuff like that will done from Document Level JavaScript,, Thanks for your help.

            • 3. Re: Restoring Button Position
              Thom Parker Adobe Community Professional

              Why yes, there are global variables in Acrobat JavaScript where the original position could be stored. For example, this codes stores a field rectangle into a document level variable. The scope of the variable is the document object, and it's lifetime is the lifetime of the document.

               

              this.SaveRect = this.getField("Button1").rect;

               

              You could also save to the global object.

               

              global.SaveRect = this.getField("Button1").rect;

               

              You can even make global objects persistent across Acrobat sessions.

               

              I suggested a hidden field because it is persistent with the document, which is where the buttons live. If you don't need persistence, then a document level variable is easier than a field.

              1 person found this helpful