20 Replies Latest reply on Sep 21, 2012 7:49 AM by de-bunk

    Copy paste buttons

    de-bunk

      Hey,

       

      I frequently need to copy paste groups of several element, which include buttons, into frames (in order to create scrollable frames for DPS), and every time I do that with a "Go to State" buttons, they lose their properties and I have to recreate them, which is pretty cumbersome to do, and especially so when the button isn't in the visible part of the frame.This happens both in CS5.5 and CS6

       

      Is there any way to past a button into a frame without losing the button's action?

       

      Thanks

        • 1. Re: Copy paste buttons
          BobLevine MVP & Adobe Community Professional

          Do these buttons control MSOs? If so, that's a known issue and quite frankly a royal pain.

           

          Bob

          • 2. Re: Copy paste buttons
            de-bunk Level 1

            Yes, they do... And indeed a royal pain.

             

            Thanks though

            • 3. Re: Copy paste buttons
              BobLevine MVP & Adobe Community Professional

              BTW, there is a dedicated DPS forum. For any DPS specific questions you should post there.

               

              Bob

              • 4. Re: Copy paste buttons
                Laubender Adobe Community Professional & MVP

                @Bob – All "go to" but the "go to State" targets of MSOs  remain intact.
                That should be corrected soon. And you are right: it is a "royal pain"…

                 

                If you duplicate buttons, all targets remain intact. But there is no way to move or duplicate a button inside (better: to) another object.
                Even with scripting, it seems that is not possible.

                 

                What you could do with scripting is adding a new generic button object to e.g. a rectangle (the scrollable frame) and transfer all properties from another button object (the one you like to paste inside) to that new added one.

                 

                I did not write such a script, but I think it's feasible…

                 

                Uwe

                • 5. Re: Copy paste buttons
                  BobLevine MVP & Adobe Community Professional

                  Thanks for the clarification. I should have pointed it out but I wanted to make sure that was the problem.

                   

                   

                   

                  I’m working on a project that has a ton of very large (30 or more states in some) and you can imagine the time it’s taking me to do the buttons.

                   

                   

                   

                  Bob

                  • 6. Re: Copy paste buttons
                    Laubender Adobe Community Professional & MVP

                    @Bob – yesterday I began writing a script snippet that is something like a proof of concept, that it is possible to duplicate a button to a rectangle or any kind of object that can hold a button object.

                     

                    But before presenting that, let me explain its basic functionality.

                     

                    1. In scripting we have one principle method to get a duplicate of a button object and therefore not losing the target MSO information: the duplicate() method.


                    2. duplicate() applied to a "Button" object will not get us in the right direction, because the target of the duplicate() method can only be a "Spread", a "Page" or a "Layer". Or you could move the duplicated button with  x/y values on a spread or a page. The target could not be a rectangle or a state in an MSO. So this seems to be a dead end.

                     

                    3. But, and here comes the clue, you are able to move or duplicate a "Character" or a "Texts" object from one text frame to another. And this is the key to a possible solution:

                     

                    If you are working with anchored objects ("Button", "Groups of Buttons" or any other object that you could paste inside of an insertion point in a text frame), you could duplicate or move that object around. The "Button" in this case is simply represented as a "Character" object that flows with the text frame.

                     

                    For "Texts" objects (and a single character (=anchored button) is a subset of "Texts") the duplicate() method supports the following parameters:

                     

                    1. The position of the duplicated character in regards of the target insertion point or text:

                    LocationOptions.AFTERPlaces the object after the reference object.
                    LocationOptions.AT_BEGINNINGPlaces the object at the beginning of the containing object.
                    LocationOptions.AT_ENDPlaces the object at the end of the containing object.
                    LocationOptions.BEFOREPlaces the object before the reference object.
                    LocationOptions.UNKNOWNNo location specified.

                     

                    2. The target (a "Texts" object, a insertion point, a character, a word, a paragraph) could be the same text frame of the original anchored button or a different text frame. And that could be a new text frame, that could be easily added to a rectangle, a state of an MSO etc.pp. with:

                     

                    myRectangle.textFrames.add();
                    

                     

                     

                    That implies we only need two ingredients to make that concept work:

                     

                    A source text frame and a target text frame.

                     

                    The source is a text frame that holds an anchored button and should be easily identified by the script. The user (you) could do this by renaming it in the Layers Panel. Just replace its generic name "<Textframe>" with "Source".

                     

                    The target could be a rectangle. For ease of use it could be a selected rectangle and the script will work with the selection.

                     

                    What the script is doing:
                    It identifies the source text frame by its name (therfore it should be unique in the document) and duplicates all its characters (eg. the anchored button, but could be any anchored object) to a new text frame that will be added on the fly to the selected rectangle.

                     

                    And here comes the script (JavaScript):

                     

                    //DuplicateAnchoredObjectsTo_SELECTION.jsx
                    //DESCRIPTION:Just a proof of concept!
                    //Uwe Laubender
                    
                    /**
                    * @@@BUILDINFO@@@ DuplicateButtonTo_SELECTION.jsx !Version! Sat Sep 15 2012 19:39:03 GMT+0200
                    */
                    
                    
                    var myDoc = app.documents[0];
                    var mySel = app.selection[0];
                    try{
                    var mySource = myDoc.pageItems.itemByName("Source").texts[0];
                    var myTarget = mySel.textFrames.add({geometricBounds:mySel.geometricBounds}).insertionPoints[0];
                    
                    mySource.duplicate(LocationOptions.AFTER,myTarget);
                    }catch(e){alert(e.message)};
                    

                     

                    It's not exactly the thing you like to do, because it requires some preparations:

                     

                    you have to anchor the object you like to duplicate,

                    you have to define the target MSO after you anchored the source button,

                    you have to rename the text frame

                     

                    and:

                     

                    you get an additional text frame at the target rectangle and that is adding some complexity to the structure of your document, but hey, it's working…

                     

                     

                    Here are some screen grabs to illustrate the preparation of the source and showing the results after running the script:

                     

                    1. Prepare the button as an anchored object (sorry, but the UI is in German, but I think you'll get it):

                    Step1_AnchorTheButton.png

                     

                     

                    2. Rename the source text frame from "<Textframe>" to a unique name.

                    In this case: "Source":

                    Step2_RenameTheTextFrame.png

                     

                    3. Define the target MSO in the button at that stage.

                    By copy/paste the button to the text frame you already lost the target MSO.

                    Step3_DefineTheGoToMSOTargetOfTheButton.png

                     

                    4. Select the target rectangle you want to duplicate the button to:

                    (the green rectangle represents the first state of the MSO on this spread. It's just an example)

                    Step4_SelectTheTarget_Rectangle.png

                     

                    5. Run the script:

                    Step5_StartTheScript.png

                     

                    6. Inspect the results:

                    6.1 The button sits in the selected rectangle

                    Step6_AFTER_TheScript.png

                    6.2 To be precise: it's the first character in a text frame that is added to the target rectangle.
                    The added text frame has the exact size and position of your selection:

                    Step7_InspectTheTarget_LayersPanel.png

                    6.3 Inspect the button: the target  is not lost. The MSO is still addressed by the button:

                    Step8_InspectThePropertiesOfTheButton.png

                     

                    Instead of a single button as the source, you could use a variety of objects:

                    groups, several buttons anchored one after another etc.pp.

                     

                    And remember: this is just a proof of  concept so error management is hardly implemented.

                     

                    Uwe

                    • 7. Re: Copy paste buttons
                      BobLevine MVP & Adobe Community Professional

                      Nice work…at least the parts that I can understand.

                       

                       

                       

                      What would be even nicer is if they fixed this. I complain much but this issue set me back quite a bit of time on the project I’m working on now.

                       

                       

                       

                      Bob

                      • 8. Re: Copy paste buttons
                        Laubender Adobe Community Professional & MVP

                        @Bob – I agree.

                         

                        Sometimes I think to myself: don't write a script to work around an issue, because that will lessen the pressure on Adobe to fix the problem…

                         

                        Uwe

                        • 9. Re: Copy paste buttons
                          Laubender Adobe Community Professional & MVP

                          @Bob – maybe it's more effective for DPS users to move the whole thread to the DPS forum.

                           

                          Uwe

                          • 10. Re: Copy paste buttons
                            Laubender Adobe Community Professional & MVP

                            @Bob – and another thing: with that script snippet I only tackled a fraction of the real problem.

                             

                            There should be a method to duplicate or copy a MSO (and the inserted buttons, that control its states) and retain the target (the duplicated or copied MSO).

                             

                            This requires another fix.

                             

                            Uwe

                            • 11. Re: Copy paste buttons
                              BobLevine MVP & Adobe Community Professional

                              I just did a huge project with loads of MSOs and I copy/pasted them between files. The buttons remained intact.

                               

                               

                               

                              I’ve never tried to copy/paste an MSO within an InDesign file.

                               

                               

                               

                              As for moving this, I think it’s okay here. MSOs are used for SWF as well as DPS. If you want to you could copy/paste the post to the DPS forum.

                               

                               

                               

                              Bob

                              • 12. Re: Copy paste buttons
                                Laubender Adobe Community Professional & MVP

                                I just did a huge project with loads of MSOs and I copy/pasted them between files. The buttons remained intact.

                                 

                                You are right: the issue appears, if you copy/paste or duplicate the MSO within an InDesign file.

                                 

                                //Edit: I have to correct myself. The problem lies in the "duplicate" action.

                                 

                                Uwe

                                 

                                Message was edited by: Laubender

                                • 13. Re: Copy paste buttons
                                  de-bunk Level 1

                                  Laubender wrote:

                                   

                                  2. duplicate() applied to a "Button" object will not get us in the right direction, because the target of the duplicate() method can only be a "Spread", a "Page" or a "Layer". Or you could move the duplicated button with  x/y values on a spread or a page. The target could not be a rectangle or a state in an MSO. So this seems to be a dead end.

                                   

                                   

                                  This is helpful, but doesn't address one of my main problems, which is to paste a group of objects, including some buttons, into a frame, in order for that frame to serve as a scrollable frame.

                                   

                                  From your explanation, I guess there isn't a soluition to that until Adobe fixes the duplicate() function. (which, by the way, is why I initially posted it in the indesign forum, not the DPS one, as far as I can understand it's a problem related indesign's code, not DPS code)

                                  • 14. Re: Copy paste buttons
                                    BobLevine MVP & Adobe Community Professional

                                    It is indeed an InDesign problem but it affects DPS users mostly. The discussion does belong here.

                                     

                                    Bob

                                    • 15. Re: Copy paste buttons
                                      Laubender Adobe Community Professional & MVP

                                      @de-bunk – well, you could anchor that group of buttons to a text frame, preparing the "Source" and run the script snippet.
                                      But this means you have to set your target states after the anchoring.

                                       

                                      If you need that particular group of buttons more than one time in more than one frame, the added time for preparing the source and running the script could be a benefit…

                                       

                                      Uwe

                                      • 16. Re: Copy paste buttons
                                        de-bunk Level 1

                                        Laubender wrote:

                                         

                                        If you need that particular group of buttons more than one time in more than one frame, the added time for preparing the source and running the script could be a benefit…

                                         

                                        But scrollable frames can only be graphic frames. once I will paste the source text-box into the frame, the buttons will lose their attributes again. Won't they?

                                        • 17. Re: Copy paste buttons
                                          Laubender Adobe Community Professional & MVP

                                          @de-bunk – no. Therefore the script.

                                           

                                          Ok. I'll explain it again:

                                           

                                          1. Group your buttons.
                                          2. Copy/Paste them into a text frame

                                          3. Make the Group an anchored object as shown in screengrab 1 in my answer 6
                                          4. Then: apply the targets (your MSO states) to the buttons

                                          5. Rename the text frame to "Source" in the Layers Panel

                                          6. Select the graphic frame, the one that you like to use as "Scrollable Frame"

                                          7. Run the script

                                           

                                          The script does the following:

                                           

                                          It adds a NEW text frame to your selected frame.
                                          It "duplicates" ("duplicate" is a different action than "copy/paste") the text (your anchored group) to the new text frame inside your graphic frame (your selection).

                                           

                                          The main point is: if you duplicate a button (in contrast to copy/paste), the MSO tragets do NOT get lost.

                                           

                                          Uwe

                                          • 18. Re: Copy paste buttons
                                            Laubender Adobe Community Professional & MVP

                                            @de-bunk – if it happens that your "Group Of Objects" contains an MSO with buttons inside that MSO, you will lose the target states of your buttons, because bug #2 will bite you:

                                             

                                            Bug #2: Duplication of MSOs will yield to lost target states of all buttons inside that MSO.

                                             

                                            If you also have buttons in the group outside of the MSO in the same group, their targets will stay intact.

                                             

                                            For this situation we need another script. Or an addition to the script snippet I presented here.
                                            A snippet that detects, if buttons sit inside that MSO and also detect what MSO is their parent MSO and apply that parent  as target.

                                             

                                            Uwe

                                            • 19. Re: Copy paste buttons
                                              Laubender Adobe Community Professional & MVP

                                              And to write such an addition is quite a tough task, because there is no easy way to determine if an MSO contains any buttons in states that are not the "Active State" (that's the one you can see and is exposed to  the "Layers Panel").

                                               

                                              The (yet not written) script has to go through all states of all the MSOs in the "Group" duplicated to the "Scrollable Frame" and make it the "Active State" one after another and then manipulate the buttons it will find in the "Active State"…

                                               

                                              Uwe

                                              • 20. Re: Copy paste buttons
                                                de-bunk Level 1

                                                Thanks for the thorough explanation. I think bug#2 will still hit me very often, but this is useful nontheless. If you ever end up writing that second script, please do share.

                                                 

                                                Now, if Adobe could fix these bugs...

                                                 

                                                Thanks