7 Replies Latest reply on Nov 15, 2012 5:47 PM by George_Johnson

    Circling a word by clicking on it

    GameHermit Level 1

      Is there a way to click on a word in a PDF document and have that word circled (or boxed in with a border)? A friend asked me to work on a Character sheet for his game and a few of the selections aer made by "circling" a choice. Example: Good / Evil (the player would circle one or the other). As an alternate...it would be cool if the player could click on one word and have the other word striked-through (Example: The player chooses "Good" so the sheet would look like this... Good / Evil

       

       

      I'm pretty good with all of the other calculations on this sheet but this one has me stumped. They didn't want a radio select.

       

       

      Thanks for looking at this with me

       

       

      Jack

        • 1. Re: Circling a word by clicking on it
          George_Johnson MVP & Adobe Community Professional

          You can set up a button so that it appears to circle a word, though it's really an ellipse. It's a lot easier to toggle the button's border, however, which would be a rectangle. You could use a similar technique to do a strikethrough.  Here's some code you can use in a button's Mouse Up event to toggle the border color from nothing (transparent) to red:

           

          // Mouse Up script for button

          (function () {

           

              // Get this button's current border color

              var cc = event.target.strokeColor;

           

              // Toggle this button's border color between transparent and red

              event.target.strokeColor = color.equal(cc, color.transparent) ? color.red : color.transparent;

           

          })();

           

           

          To toggle a strikethrough instead, you could do this:

           

          // Mouse Up script for button

          (function () {

           

              // Define a string to use for the strikethrough text

              var strikethrough_text = "------";

           

              // Determine this button's new label

              var nc = event.target.buttonGetCaption() === "" ? strikethrough_text : "";

           

              // Toggle this button's label

              event.target.buttonSetCaption(nc);

           

          })();

           

           

          You can change the number of hyphens to match the word you want to strikethrough and change the size of the button to suit.

           

          If you really want to encircle a word, post again and I can provide a link to a demo.

          • 2. Re: Circling a word by clicking on it
            GameHermit Level 1

            Hi George...thanks for the response!!! I thought about using one of these methods but really didn't know how to do it...thank you so much. I'll post back with the results

             

            Jack

            • 3. Re: Circling a word by clicking on it
              GameHermit Level 1

              Hey George....the rectangle button border worked beautifully!!!! Thank you so much!

               

              If you get the chance...I would liek to check out the encircle demo you mentioned...that might be really cool

               

              Thanks again for all of your help.

               

              Jack

              • 4. Re: Circling a word by clicking on it
                George_Johnson MVP & Adobe Community Professional

                Here's a link to a demo I put together a while back: https://workspaces.acrobat.com/?d=JBzD4guSToeYu0qLkvfvgA

                 

                It is probably more complicated than it needs to be for your purposes. For each button that's used to provide a circle, there is a companion text field, which would normally be hidden. This allows the composite field (button+text field) to have a value, one that can be set by importing field data and via script. If you just need to toggle the button appearance (icon), the code can be much simpler.

                • 5. Re: Circling a word by clicking on it
                  GameHermit Level 1

                  Hi George...this is excellent! I can follow the code pretty well...my only question (thus far...LOL) is where the red circle icon is being pulled. Is it coming from the button at the top left?e text...the

                   

                  I won't be using alternate text...these buttons just go over a pregenerated page and the words are not editable. So will this make the code simpler?

                   

                  Thanks,

                   

                  Jack

                  • 6. Re: Circling a word by clicking on it
                    GameHermit Level 1

                    Nevermind...figured it out once I understood how it all worked. This is awesome...thank you so much!

                     

                    I created an icon in Illustrator then applied a stroke effect so now it looks the word is circled in pencil when selected

                    • 7. Re: Circling a word by clicking on it
                      George_Johnson MVP & Adobe Community Professional

                      Cool, glad you found it useful.