7 Replies Latest reply on Aug 27, 2014 12:13 AM by Trevorׅ

    Is it possible to run the script every time i select a TextFrame

    MohamedYousif

      Hi all,

       

      I am new to JavaScripting and i have a question and problem. I have a set of linked text frames, what i need is when the user click to select any text frame, the script automatically initiated and  select all Linked text frames. Is it Possible to do ??? and if Yes how can i do that.

       

      Thanks in advance,

        • 1. Re: Is it possible to run the script every time i select a TextFrame
          Laubender Adobe Community Professional & MVP

          @Mohamed – to write a script, that can react to the selection of a text frame is possible.
          That would be an event driven script that uses an eventlistener that reacts on an afterSelectionChanged event.


          To select all threaded text frames (containers) of a story is only possible for the ones on a single spread.
          Any user selection of page items can only be spread wise. Opposed to text where you can select the whole story with the text tool that can span several spreads.

           

          On the other hand: To do something to all threaded text frames (containers) of a story (without selecting them) is possible, if you provide your own user interface where the user has to interact with or let the script work in the background totally automatically.

           

          What likes the user to do after "all" possible text frames of a story are selected or reached?

           

          Uwe

          • 2. Re: Is it possible to run the script every time i select a TextFrame
            MohamedYousif Level 1

            Laubender, It's great to hear that it possible to do, but can you refer me to a documentation or any thread to learn how to write an eventlistener.

            • 3. Re: Is it possible to run the script every time i select a TextFrame
              Laubender Adobe Community Professional & MVP

              @Mohamed – before doing anything with an eventlistening process or writing some code or suggesting something, I have to know the whole story (still not answered for me):

               

              Your idea is: Select all text frames of a story every time a text frame is selected.

               

              Is that a good thing for the user? If I would work in such an environment, this would get to my nerves.

               

              I said (and hopefully made that clear): Not possible in one go, if the text frames populate different spreads of the document. So a new question would arise immediately: What should happen in that case?

               

              And also:

               

              Should the user be able to start the process?

              Should the user be able to stop the process?

               

              What likes the user to happen automatically to all containers of a story in the moment a text frame is selected?

              Just one thing this time? A different thing the next time?

               

              Writing event driven scripts is not the easiest task. And it is very time consuming when it comes to testing things.

              So I could only hint to the following: Search this very forum for "eventListeners" and read thoroughly before attempting anything.


              Without answering the questions above (and following ones that will arise from your answers) it's impossible to give good advice.

               

              Uwe

              • 4. Re: Is it possible to run the script every time i select a TextFrame
                MohamedYousif Level 1

                Laubender actually i will not select all text frames of the story i will select only the linked text frames with some conditions e.g., if i have a Long Table Flowed over more than TextFrame, i need the user when select any text frame from the group, all linked text frames selected. am i Clear??? then, any change on a frame will affect all linked frames also movement of a frame will move all linked frames keeping their position distance equal.

                Thanks

                • 5. Re: Is it possible to run the script every time i select a TextFrame
                  Laubender Adobe Community Professional & MVP

                  No. Sorry, I do not get it. It's still not clear to me…

                   

                  Can you show some screenshots that illustrate: The state before a user selects a text frame and the state after the user selects a text frame with a simpe example?

                   

                  I'm a little confused over your usage of the expression "linked" and "group".

                  I only can see that you want to synchronize something…

                   

                  Btw.: What InDesign version?

                   

                  Uwe

                  • 6. Re: Is it possible to run the script every time i select a TextFrame
                    MohamedYousif Level 1

                    Ok, the next screenshots show an example of what i need.


                    1.The first screenshot shows that i have 3 textFrames linked to each other (That is what i mean with Linked).

                    Indesign linked 1.png

                     

                    2. The Second one shows that the end result of selecting one frame, the 3 textFrames selected (That is what i mean with Group "group of linked frames").

                    Indesign linked 2.png

                    3. The Third screenshot shows that i try to move the frames and all of frames moved together.


                    Indesign linked 3.png

                     

                    4. The last screenshot shows the new position after moving and shows that all frames keeping their position distance equal.

                    Indesign linked 4.png



                    I hope that clear enough to describe my point of view, I use InDesign CC 2014 Laubender

                     

                    Thanks,

                    • 7. Re: Is it possible to run the script every time i select a TextFrame
                      Trevorׅ Adobe Community Professional

                      Hi

                       

                      Looks to me that your work flow should be

                      apply eventListener  to check

                      Does frame contain a table?

                      If yes is the table overflowing from a previous text frame or does it overflow to the following one?

                      If yes are all the text frames on the same spread?

                      If yes record the location on the page of the text frames

                      On making a new selection update the location of all the linked text frames if they stay on the spread

                      Or make an for a live effect add an afterSelectionAttributeChanged eventListener to monitor the movement of the textFrames and update the location of all the relevant text frames accordingly.  Remove that eventListener on deselecting the frame.

                      Use textFrame IDs to make sure you a monitoring the correct one's.

                       

                      See the manual for example eventListeners.

                      It's quite tricky for a beginner with quite a few hazzards. So you might want to hire someone.

                       

                      Trevor