7 Replies Latest reply on Jul 1, 2009 8:02 AM by macian2

    Is there a "Drag-Select" Method?

    macian2

      I remember many years ago when Aldus PageMaker was popular. In that program I was able to script and perform a "drag-select" in a specific area of choice.

       

      Can anyone describe or offer any ideas on how to go about this using Applescript or with Javascript?

       

      (Ps: I only understand applescript, but lets have fun and discover new ways to do something new and learn at the same time!)

       

      Thank you everyone...

        • 1. Re: Is there a "Drag-Select" Method?
          Thomas B. Nielsen Level 3

          I'm not quite sure what you actually want to achive, but you can get the current selection in a document with:

          app.activeDocument.selection (JS)

           

          This is all the selected items in this document.

          • 2. Re: Is there a "Drag-Select" Method?
            macian2 Level 1

            Howdy Thomas B. Nielsen,ing

             

            Thanks for responding...

             

            I should explain further what I refer to "drag-select" means:

             

            "Drag-Select" would be equivalent to placing your 'Selection Tool' anywhere on the page and drag-selecting to another area on the same page. What ever was captured within the drag "marquee" area would then be actively selected. Now, you could do what you like the the selected objects; be it a text frame, graphic, etc.

            • 3. Re: Is there a "Drag-Select" Method?
              Thomas B. Nielsen Level 3

              As i thought, my answer apply.

               

              Drag and select with the mouse, a script will now have acess to the selected objects through:

              app.activeDocument.selection

               

              However, You will manually have to tell the script, operating on the selected objects, to run. Either by clicking a script in the script palette or by having some sort of Script UI dialog button pressed.

               

              Try the following, create a document, select some objects, run this javascript:

               

              var myDocument = app.activeDocument;

              var mySelObjects = myDocument.selection;

               

              for (i=0; i<mySelObjects.length; i++) {

                   alert(mySelObjects[i].constructor.name);

              }

              • 4. Re: Is there a "Drag-Select" Method?
                macian2 Level 1

                Howdy Thomas B. Nielsen,

                 

                Thanks for responding...
                I can almost feel the creative juices bubbling out there in the ethers!

                 

                The idea provided, looks great, but my understanding of javascript is so-so. I am learning...

                 

                My question would be to you or anyone:  Could I designate a "start coordinate" and drag-select in theory to an "end coordinate" in the javascript?

                 

                I would further detail my question to all:  i.e.  I have thirty pages in a one of many documents that have a specific area on each page that contains items that are no longer needed and are to be deleted. There are no labels to identify, etc.
                I hope this description provides a better view of my request for a solution.

                 

                Thank you all...

                • 5. Re: Is there a "Drag-Select" Method?
                  [Jongware] Most Valuable Participant

                  You can't move the mouse using Javascript.

                  I think I would go the other way:

                  1. determine upper-left and lower-right coordinates of interest
                  2. Loop over every page
                  3. On every page, loop over every object
                  4. Compare its geometric bounds against the ul/lr coordinates
                  5. Delete the objects that are entirely within those.

                   

                  Sounds simple, eh? (I'm pretty sure rotated objects will cause trouble )

                  (Another point is that ID's default ruler setup is per spread, not per page -- but that might be taken into account as well.)

                  • 6. Re: Is there a "Drag-Select" Method?
                    sstanleyau Level 4

                    This will let you act on all items whose top left fall within a range of coordinates; you could easily modify it to deal with items contained by the ranges:

                     

                    tell application "Adobe InDesign CS3"

                    tell document 1

                    <do something to> (every item of all page items of page 1 where item 1 of its geometric bounds is greater than 72 and item 1 of its geometric bounds is less than 400 and item 2 of its geometric bounds is greater than 72 and item 2 of its geometric bounds is less than 500)

                    end tell

                    end tell

                     

                     

                    --

                    Shane Stanley <sstanley@myriad-com.com.au>

                    AppleScript Pro Sessions <http://scriptingmatters.com/aspro>

                    1 person found this helpful
                    • 7. Re: Is there a "Drag-Select" Method?
                      macian2 Level 1

                      Howdy everyone,

                       

                      Well, I have to say, that the sample applescript from Shane Stanley had the same effect as did that of "old PageMaker's" exclusive scripting. By designating a specific area and then asking if any objects (in this case, item 1 of the geometric bounds), fell within that area, was definitely the solution.


                      For demonstration purposes on my part, I replaced the <do something to> to "select" as follows...

                       

                      tell application "Adobe InDesign CS3"

                      tell document 1
                      select (every item of all page items of page 1 where item 1 of its geometric bounds is greater than 72 and item 1 of its geometric bounds is less than 400 and item 2 of its geometric bounds is greater than 72 and item 2 of its geometric bounds is less than 500)
                      end tell
                      end tell

                       

                      This worked wonderfully... by-the-way, the unit of measurement is in points.

                       

                      Again, thanks to all who offered solutions and to Shane Stanely, for what I believe is the answer to my "Is there a "Drag-Select" Method?" question!