12 Replies Latest reply on Feb 19, 2013 2:20 PM by Laubender

    Keep layout position when using Find/Change?

    Alicia ALD

      When using Find/Change in InDesign CS4, each occurrence of the "Found" material is centered in the window, so the page moves around with each find. Is there a way to keep the page in a fixed position when searching through a document?

        • 1. Re: Keep layout position when using Find/Change?
          Tom Usrey Level 3

          No. The behavior you are describing is a "feature" with no options.

          • 2. Re: Keep layout position when using Find/Change?
            Alicia ALD Level 1

            Okay; thank you. Good to know.

            • 3. Re: Keep layout position when using Find/Change?
              TᴀW Adobe Community Professional & MVP

              Hi Alicia,

               

              What specifically would you like to happen? How about if, for instance,

              the entire spread is displayed each time you jump from one find to the next?

               

              Ariel

              • 4. Re: Keep layout position when using Find/Change?
                Alicia ALD Level 1

                Hi, Arïel,

                 

                Yes, that's exactly what I'm looking for. I'm toggling between two versions of the same spread, updating one based on the other, and it would be easier on the eye if the text frames stayed in the same place on the screen.

                 

                Alicia

                • 5. Re: Keep layout position when using Find/Change?
                  TᴀW Adobe Community Professional & MVP

                  Hi Alicia,

                   

                  I don't have much time right now, so I'm going to try and post the

                  following script via the email interface. In the past, this has caused

                  the script to become mangled and not work, but that hasn't been

                  happening recently, so maybe the forum software has been fixed. If it

                  doesn't work, I will get back to it after Shabbat (the Jewish Sabbath).

                   

                  Run the script once, and InDesign will always try and keep the spread

                  displayed (not just for find change, but any time the selection of

                  anything changes). Run the script again to revert to the regular behaviour.

                   

                  The script does take up some resources, I think, so could be some things

                  will run slower, don't know. I haven't noticed any adverse effects, but

                  it's a little experimental!

                   

                  Anyway, here it is:

                   

                  #targetengine foo1

                  var myEName = "Always show spread";

                  var myFound = false;

                  for (var a = app.eventListeners.length-1; a>=0; a--){

                       if (app.eventListeners[a].name == myEName){

                           app.eventListeners[a].remove();

                           myFound = true;

                       }

                  }

                  if (!myFound){

                       var myEvent = app.addEventListener("afterSelectionChanged",

                  function(){app.activeWindow.zoom(ZoomOptions.FIT_SPREAD)});

                       myEvent.name = myEName;

                  }

                   

                  Hope it helps!

                   

                  Ariel

                  1 person found this helpful
                  • 6. Re: Keep layout position when using Find/Change?
                    Alicia ALD Level 1

                    Hi, Ariel,

                     

                    I wasn't able to get the script to work, but that may just be my lack of savvy about scripts. What I did was to paste the text of the script into the ExtendScript ToolKit CS4 and save it as a .jsx file to the Scripts Panel folder. When I double-click it in ID I get this message:

                     

                    JavaScript Error!

                     

                    Error Number: 55

                    Error String: Object does not support the property or method 'name'

                     

                    File: gives the file location

                    Line: 5

                    Source: if(app.eventListeners[a].name = = myEName){

                     

                     

                    I'm probably doing something dumb. No rush on this--

                     

                    Alicia

                    • 7. Re: Keep layout position when using Find/Change?
                      TᴀW Adobe Community Professional & MVP

                      Hi Alicia,

                       

                      What you did is what needs to be done. Unfortunately, the script won't

                      work on CS4 (I just tried it myself and got the same error you do). (It

                      uses an eventListener which didn't exist then, yet).

                       

                      It does work on CS6. Don't know about CS5.

                       

                      Sorry!

                       

                      Ariel

                      • 8. Re: Keep layout position when using Find/Change?
                        Laubender Adobe Community Professional & MVP

                        @Arïel – "afterSelectionChanged" is exclusively InDesign CS6.


                        To achieve something like this in InDesign CS4, I think we have to rebuild the "whole" UI for search/replace as a custom palette window, list the found texts (in a scrollable sub-window?)  so that the user can click at a found item to navigate to (or uses controls like: "select", "next item", "previous item").

                         

                        The last part (the easy one), once the user clicked the found item in the UI controls of the custom palette, would be to select the particular text item and zoom the active window to spread wide.

                         

                        Here a snippet for the last, the easy part:

                         

                        if (myFoundText != null){ 
                            app.select(myFoundText, SelectionOptions.REPLACE_WITH);    
                            app.activeWindow.zoom(ZoomOptions.FIT_SPREAD);  
                            };
                        

                         

                        However, I have left out the hard part ;-)

                         

                        So, @Alicia, this snippet is not working for you!
                        It's just part of my outlined solution strategy…

                         

                        Uwe

                        • 9. Re: Keep layout position when using Find/Change?
                          TᴀW Adobe Community Professional & MVP

                          Actually, I can think of a shortcut for the hard part: The user uses the

                          regular find/change UI to make all their settings. Then, they run the

                          script, which will simply use the settings in the UI. Nice, huh! So you

                          could get a listBox of all the finds -- select the entry and you get

                          taken to the desired location. Click the "change" button and the change

                          is made. Here's a proof of concept:

                           

                          #targetengine engine20

                          var myFinds = app.findText();

                          var w = new Window("palette");

                          var myList = w.add("listbox", undefined, myFinds);

                          var changeButton = w.add("button", undefined, "Change");

                          myList.onChange = gotoFound;

                          changeButton.onClick = makeTheChange;

                          w.show();

                           

                          function gotoFound(){

                          app.select(myFinds[myList.selection.index].parentTextFrames[0].parent.parent);

                               app.select(myFinds[myList.selection.index]);

                          }

                           

                          function makeTheChange(){

                               myFinds[myList.selection.index].changeText();

                          }

                           

                          Obviously very rudimentary: but this does work in CS4. If the list is

                          too long, though, the change button will disappear off the bottom of the

                          screen. Also, really once the change is made, the item should be removed

                          from the list, but there's a bug in CS4 that makes it impossible to do

                          that simply, if I recall correctly (or was that only a tree list?)

                           

                          Also, I have found that the only sure way of getting the entire spread

                          to show is as I've done it above (and it would need much more error

                          checking than this -- for instance, overset text).

                           

                          Ariel

                          • 10. Re: Keep layout position when using Find/Change?
                            Laubender Adobe Community Professional & MVP

                            @Arïel – wow! Congratulations!
                            This is very, very cool!!

                             

                             

                            I can see some possible enhancements:

                            An additional button: "Select only"

                             

                            A field where the user can input a value as zoom percentage to the found item with a couple of predefined values like "Fit page in window" or "Fit spread in window" or "100%" or "200"…

                             

                            And of course, other than listing the found objects as "[object Word]" or [object StyleRange] etc.etc. (that depends on the specific search), we could depict the "contents" of the found items together with their page names or numbers!

                             

                            I am excited!!

                             

                            Uwe

                            • 11. Re: Keep layout position when using Find/Change?
                              TᴀW Adobe Community Professional & MVP

                              Thanks. Yes -- it's rife with potential...

                               

                              It should probably have an option for find text and find GREP also.

                              Maybe a couple of radio buttons or something.

                               

                              Ariel

                              • 12. Re: Keep layout position when using Find/Change?
                                Laubender Adobe Community Professional & MVP

                                Yeah…
                                And "Sorting by Page", "This Page Only" etc…

                                 

                                Something to sleep over (It's 11:20pm here in my part of the world) :-)

                                 

                                Uwe