8 Replies Latest reply on Jun 20, 2016 6:48 AM by Aquoibon

    Indesign selection and dialog box … bug ?

    Aquoibon Level 1

      Hello,

      is there someone who could explain to me why : "app.select(T.rows[1].cells.itemByRange(0,-1))" works fine in the first time

      and the "app.select(Tableau.columns[1].cells.itemByRange(0,-1))" doesn't work after the "Clic !!!!" in this script (you need an open document and to be in a table).

      Thank a lot for any help.

       

       

      // SCRIPT

      function Fenetre(){

        var FENETRE = new Window("dialog", "TEST");

        var BTN = FENETRE.add("button", undefined, "Clic !!!!");

        BTN.onClick = function(){

        FENETRE.close();

        Start();

        }

        FENETRE.show();

      }

       

       

      function Start(){

        alert("START")

        var Cellule = app.selection[0];

        var Tableau = app.selection[0].parent;

        if (Cellule.constructor.name == "Table"){

        Tableau = app.selection[0];

        }

        if (Tableau.constructor.name == "Cell"){

        Cellule = Cellule.parent;

        Tableau = Tableau.parent;

        }

       

       

        app.select(Tableau.columns[1].cells.itemByRange(0,-1));

        alert("fin")

      }

       

       

      var C = app.selection[0];

      var T = C.parent;

      app.select(T.rows[1].cells.itemByRange(0,-1));

      Fenetre();

        • 1. Re: Indesign selection and dialog box … bug ?
          Loic.Aigon Adobe Community Professional

          Hi,

           

          You are presuming T is a table object while it might be actually a Cell object. Cell object does not have a rows collection which leads to your execution error.

           

          Given that you have an insertionPoint inside a cell as a selection, here is a fix:

           

          var S = app.selection[0];
          var C = S.parent;
          var T = C.parent;
          var Rs = T.rows;
          var r = Rs[0];
          app.select ( r );
          

           

          HTH

           

          Loic

          Ozalto | Productivity Oriented - Loïc Aigon

          • 2. Re: Indesign selection and dialog box … bug ?
            Aquoibon Level 1

            Bonjour, merci, mais non … ooops !

             

            Car en fait la partie de script envoyée n'est que parcellaire et je m'en excuse.

            J'ai en fait un test en amont pour confirmer que la sélection est une cellule ou pas.

             

            Ce n'est pas cette partie qui pose problème :

            var C = app.selection[0];

            var T = C.parent;

            app.select(T.rows[1].cells.itemByRange(0,-1));

             

             

            Mais bien celle-ci :

            function Start(){

                 alert("START")

                 var Cellule = app.selection[0];

                 var Tableau = app.selection[0].parent;

                 if (Cellule.constructor.name == "Table"){

                      Tableau = app.selection[0];

                 }

                 if (Tableau.constructor.name == "Cell"){

                      Cellule = Cellule.parent;

                      Tableau = Tableau.parent;

                 }

             

                 app.select(Tableau.columns[1].cells.itemByRange(0,-1));

                 alert("fin")

            }

             

            Qui effectue bien le test pourtant.

             

            Merci

            Alban

             

             

            Le 15 juin 2016 à 22:52, "Loic.Aigon" <forums_noreply@adobe.com> a écrit :

             

             

            Indesign selection and dialog box … bug ?

            created by Loic.Aigon in InDesign Scripting - View the full discussion

            Hi,

             

             

            You are presuming T is a table object while it might be actually a Cell object. Cell object does not have a rows collection which leads to your execution error.

             

             

            Given that you have an insertionPoint inside a cell as a selection, here is a fix:

             

             

            var S = app.selection[0];

            var C = S.parent;

            var T = C.parent;

            var Rs = T.rows;

            var r = Rs[0];

            app.select ( r );

             

            HTH

             

             

            Loic

             

            Ozalto | Productivity Oriented - Loïc Aigon

             

            If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/8814225#8814225 and clicking ‘Correct’ below the answer

            Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:

            Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/8814225#8814225

            To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"

            Start a new discussion in InDesign Scripting by email or at Adobe Community

            For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

            This email was sent by Adobe Community because you are a registered user.

            You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences

            >

            • 3. Re: Indesign selection and dialog box … bug ?
              Aquoibon Level 1

              OOOP ! pour la seconde fois, je n'avais pas vu le fichier joint …

               

              Je m'empresse de regarder tout cela.

               

              Merci beaucoup.

              Alban

               

              Le 16 juin 2016 à 09:21, bcv.creation@wanadoo.fr a écrit :

               

              Bonjour, merci, mais non … ooops !

               

              Car en fait la partie de script envoyée n'est que parcellaire et je m'en excuse.

              J'ai en fait un test en amont pour confirmer que la sélection est une cellule ou pas.

               

              Ce n'est pas cette partie qui pose problème :

              var C = app.selection[0];

              var T = C.parent;

              app.select(T.rows[1].cells.itemByRange(0,-1));

               

               

              Mais bien celle-ci :

              function Start(){

                   alert("START")

                   var Cellule = app.selection[0];

                   var Tableau = app.selection[0].parent;

                   if (Cellule.constructor.name == "Table"){

                        Tableau = app.selection[0];

                   }

                   if (Tableau.constructor.name == "Cell"){

                        Cellule = Cellule.parent;

                        Tableau = Tableau.parent;

                   }

               

                   app.select(Tableau.columns[1].cells.itemByRange(0,-1));

                   alert("fin")

              }

               

              Qui effectue bien le test pourtant.

               

              Merci

              Alban

               

               

              Le 15 juin 2016 à 22:52, "Loic.Aigon" <forums_noreply@adobe.com> a écrit :

               

              >>

              >> Indesign selection and dialog box … bug ?

              >> created by Loic.Aigon in InDesign Scripting - View the full discussion

              >> Hi,

              >>

              >> 

              >> You are presuming T is a table object while it might be actually a Cell object. Cell object does not have a rows collection which leads to your execution error.

              >>

              >> 

              >> Given that you have an insertionPoint inside a cell as a selection, here is a fix:

              >>

              >> 

              >> var S = app.selection[0];

              >> var C = S.parent;

              >> var T = C.parent;

              >> var Rs = T.rows;

              >> var r = Rs[0];

              >> app.select ( r );

              >> 

              >> HTH

              >>

              >> 

              >> Loic

              >>

              >> Ozalto | Productivity Oriented - Loïc Aigon

              >>

              >> If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/8814225#8814225 and clicking ‘Correct’ below the answer

              >> Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:

              >> Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/8814225#8814225

              >> To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"

              >> Start a new discussion in InDesign Scripting by email or at Adobe Community

              >> For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

              >> This email was sent by Adobe Community because you are a registered user.

              >> You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences

              >>

              >

              • 4. Re: Indesign selection and dialog box … bug ?
                Aquoibon Level 1

                En fait, si l'on omet le test complet pour connaitre la table (géré en amont comme je l'expliquais), et si l'on omet aussi ma programmation "non-pro" (avec les pieds) … et enfin après plusieurs tests … : le problème viendrait selon moi "uniquement" de ma gestion de la fenêtre.

                 

                Voici une version 1 bis semblable à la précédente, où :

                     - "Fenetre.close(1); " remplace "Fenetre.close(); " à la ligne 5

                     - "if ( FENETRE.show()==1 ) {Start();}" remplace "FENETRE.show();" à la ligne 8 ...

                 

                function Fenetre(){   var FENETRE = new Window("dialog", "TEST");   var BTN = FENETRE.add("button", undefined, "Clic !!!!");   BTN.onClick = function(){   FENETRE.close(1);   Start();   }   if ( FENETRE.show()==1 ) {Start();} } function Start(){   alert("START")   var Cellule = app.selection[0];   var Tableau = app.selection[0].parent;   if (Cellule.constructor.name == "Table"){   Tableau = app.selection[0];   }   if (Tableau.constructor.name == "Cell"){   Cellule = Cellule.parent;   Tableau = Tableau.parent;   }   app.select(Tableau.columns[1].cells.itemByRange(0,-1));   alert("fin") } var C = app.selection[0]; var T = C.parent; app.select(T.rows[1].cells.itemByRange(0,-1)); Fenetre();

                 

                 

                Suis-je à côté de la plaque ? Comment se fait-il ?

                Merci!

                • 5. Re: Indesign selection and dialog box … bug ?
                  Loic.Aigon Adobe Community Professional

                  Just don't call your routin on the button click but prefer running it after the window actually closed.

                   

                  DON'T

                  BTN.onClick = function(){ 

                  FENETRE.close(1);  

                  Start();

                  }

                   

                  DO

                   

                  BTN.onClick = function(){ 

                  FENETRE.close(1); 

                  }

                  if ( FENETRE.show()==1) start();

                  • 6. Re: Indesign selection and dialog box … bug ?
                    Aquoibon Level 1

                    Ok, mais cela ne m'explique pas tout … et nous revenons à ma question de départ puisque :

                    - Le test de sélection n'est pas en cause ...

                    - L'odre des actions après le "clic", lui non plus, puisque je vois l'alert de la fonction Start()

                     

                    Alors d'où vient le problème ?

                    • 7. Re: Indesign selection and dialog box … bug ?
                      Loic.Aigon Adobe Community Professional

                      Yes but fact is InDesign is still in modal state at this stage. Your code fails because Indesign is not ready to cooperate.

                       

                      SO you have to first ensure InDesign has reverted to a non modal state. That's why you have to first close the window and later once it's closed call your routine.

                       

                      OR switch window type to a non modal type such as palette or type "window".

                       

                      Loic

                      Ozalto | Productivity Oriented - Loïc Aigon

                      • 8. Re: Indesign selection and dialog box … bug ?
                        Aquoibon Level 1

                        C'est clair … tout compris.

                         

                        Merci