3 Replies Latest reply on Sep 8, 2016 5:09 AM by jakec88782761

    Linking multi column list selections in ScriptUI

    jakec88782761 Level 1

      Hello,

       

      I've got a script which has 8 columns and different items in each columns array.

      I want to make an onClick function which selects all of the items in the same index position in each column.

       

      Here is the script:

       

      var w = new Window ('dialog {text:"Blatchford Termbase",alignChildren:"fill"}');
      alert ("Welcome to Blatchford's Termbase.\nDouble click a term to be able to copy and paste it into your document.");
      w.spacing=0;

      var headers = w.add('group');
      headers.spacing=0;
      headers.margins=[0,5,0,0];
      var dimH = [0,0,200,30];

      headers.add('statictext', dimH, '\u00A0English');
      headers.add('statictext', dimH, '\u00A0French');
      headers.add('statictext', dimH, '\u00A0German');
      headers.add('statictext', dimH, '\u00A0Italian');
      headers.add('statictext', dimH, '\u00A0Spanish');
      headers.add('statictext', dimH, '\u00A0Norwegian');
      headers.add('statictext', dimH, '\u00A0Russian');
      headers.add('statictext', dimH, '\u00A0Turkish');

      headers.graphics.backgroundColor=w.graphics.newBrush(w.graphics.BrushType.SOLID_COLOR, [0.5,0.5,0.5],2);

      headers.graphics.font = "Arial-Bold:24";

      var columns = w.add('group{multiselect:true}');
      columns.spacing=0;

      var dimC = [0,0,200,600];

      var col1 = columns.add('listbox', dimC, //English
      ["1)  4 Bolt Chassis",
      "2)  Activity Level",
      "3)  add ‘D’ for a dark tone foot shell",
      "4)  Alignment",
      "5)  Any unusual noise",
      "6)  Anterior",
      "7)  Anti Rotation Feature",
      "8)  A-P shift too far back",
      "9)  A-P shift too far forward",
      "10)  Application",
      "11)  Assembly Instructions",
      "12)  Available from size 22 to size 30",
      "13)  Bench Alignment",
      "14)  Biomimetic Adjustment",
      "15)  Biomimetic Alignment",
      "16)  Blatchford Products Ltd. and ENDOLITE are companies and trademarks of Chas. A. Blatchford and Sons Ltd.",
      "17)  Build Height",
      "18)  Build Line",
      "19)  Dynamic Pylon",
      "20)  CE Conformity",
      "21)  Changes in performance may include:",
      "22)  Check the Bench Alignment and the heel height",
      "23)  Cleaning",
      "24)  Clinician's manual",
      "25)  Component Weight",
      "26)  Construction",
      "27)  Contra-indications:",
      "28)  Description and purpose",
      "29)  Dynamic Adjustment",
      "30)  Environment",
      "31)  Extra large",
      "32)  Falling backwards",
      "33)  Falling forwards",
      "34)  Fitting Length",
      "35)  Foot shell",
      "36)  Function",
      "37)  Glide Sock",
      "38)  Guidance",
      "39)  Hyperextension",
      "40)  Hyperflexion",
      "41)  Identification of Components",
      "42)  Increase in ankle stiffness",
      "43)  Instructions for Use",
      "44)  Intended for single user",
      "45)  Intended life",
      "46)  Key Product Features",
      "47)  Large",
      "48)  Liability",
      "49)  Lifting loads",
      "50)  Limitations on use",
      "51)  Maintenance",
      "52)  Maximum User Weight",
      "53)  Medium",
      "54)  Mercury knee",
      "55)  Note:",
      "56)  Operating and Storage Temperature Range",
      "57)  Order Example",
      "58)  Posterior",
      "59)  Principal parts",
      "60)  Proximal connection",
      "70)  Recommended Activity Level",
      "71)  Reduced ankle support (free movement)",
      "72)  Safety Information",
      "73)  Scheduled service at 20 months",
      "74)  See Endolite catalogue for details",
      "75)  Side",
      "76)  Size",
      "77)  Size range",
      "78)  Small",
      "79)  Technical Data",
      "80)  These instructions are for use by the Clinician/Practitioner",
      "81)  to be used exclusively as part of a lower limb prosthesis",
      "82)  Trans-femoral",
      "83)  Trans-tibial",
      "84)  Trochanter",
      "85)  User guide",
      "86)  Warranted for 3 years",
      "87)  Warranty"]);
      var col2 = columns.add('listbox', dimC, ["Dorsiflexion", "Plantarflexion","Transtibial","Transfémoral"]);        //French
      var col3 = columns.add('listbox', dimC, ["Dorsiflexion", "Plantarflexion","Trans-tibial","Trans-femoral"]);      //German
      var col4 = columns.add('listbox', dimC, ["Dorsiflexion", "Plantarflexion","Transtibiale","Transfemorale"]);     //Italian
      var col5 = columns.add('listbox', dimC, ["Dorsiflexion", "Plantarflexion","Transtibial","Transfemoral"]);        //Spanish
      var col6 = columns.add('listbox', dimC, ["Dorsiflexion", "Plantarflexion","Transtibial","Transfemoral"]);      //Norwegian
      var col7 = columns.add('listbox', dimC, ["Dorsiflexion", "Plantarflexion","Trans-tibial","Trans-femoral"]);      //Russian
      var col8 = columns.add('listbox', dimC, ["Dorsiflexion", "Plantarflexion","Transtibial","Transfemoral"]);      //Turkish

       

       


      col1.selection=0;

       

      col1.onDoubleClick=function(){
          entry.text=col1.selection;
          };
      col2.onDoubleClick=function(){
          entry.text=col2.selection;
          };
      col3.onDoubleClick=function(){
          entry.text=col3.selection;
          };
      col4.onDoubleClick=function(){
          entry.text=col4.selection;
          };
      col5.onDoubleClick=function(){
          entry.text=col5.selection;
          };
      col6.onDoubleClick=function(){
          entry.text=col6.selection;
          };
      col7.onDoubleClick=function(){
          entry.text=col7.selection;
          };
      col8.onDoubleClick=function(){
          entry.text=col8.selection;
          };

       

      var user_input = w.add('group')
      var entry = user_input.add('edittext',dimH, 'Click the button to the right to convert to lowercase');
      entry.characters=30;
      entry.alignment='left';
      entry.active=true;

       

        
         

      var convert = user_input.add('button', undefined, 'Convert to lower case');
      convert.onClick=function() {entry.text=entry.text.toLowerCase();}
      user_input.orientation='row';
      user_input.alignment='left';

          if (w.show()==1){
      (alert ("Welcome to Blatchford's Termbase.\nDouble click a term to be able to copy and paste it into your document."));
      }else{
          alert("Thank you come again")
          }
            

       

      I want to do this so hat I don't need the numbers in col1's array.

       

      Any advice would be great!

        • 1. Re: Linking multi column list selections in ScriptUI
          TᴀW Adobe Community Professional & MVP

          This function will update the French column when you click in the English column (only on the first 4 items, though, otherwise you'll get an error as there are no corresponding items in the French).

           

          col1.onChange = function(){

            col2.items[col1.selection.index].selected = true;

          }

           

          Do the same for the other columns.

           

          But it would be a good idea to use an array to hold all the columns instead of separate variables (col1, col2, etc.)

           

          That way you could just loop through all the columns, rather than type it all out individually. And you could easily add columns if needed, or delete, etc.

           

          Ariel

          • 2. Re: Linking multi column list selections in ScriptUI
            Loic.Aigon Adobe Community Professional

            When it comes to such complicated UI, I would definitively choose an event based approach:

             

            #include 'EventHandler.jsinc';
            
            
            var main  =function() {
              var w = new Window ('dialog {text:"Blatchford Termbase",alignChildren:"fill"}');
              var colGp = w.add('group');
              var n = 5;
              var firstCol = colGp.add('listbox',undefined,['a','b','c','d']); 
              colGp.orientation = 'row';
              firstCol.preferredSize = [100, 250];
            
              while ( n-- ) {
              new COL(colGp);
              }
              w.onShow = function() {
              alert ("Welcome to Blatchford's Termbase.\nDouble click a term to be able to copy and paste it into your document.");
              }
            
            
              firstCol.onChange = function() {
              if( !firstCol.selection ) {
              EventManager.dispatchEvent ( "DESELECT_ALL" );
              return;
              };
              EventManager.dispatchEvent ( "SELECT_INDEX", {index:firstCol.selection.index} );
              }
            
            
              w.show();
            }
            
            
            var COL = function(p) {
              var col = p.add('listbox', undefined, ['a','b','c','d']); 
              col.preferredSize = [100, 250];
              EventManager.addEventListener ( "SELECT_INDEX", function(data) {
              col.selection = data.index;
              });
            
            
              EventManager.addEventListener ( "DESELECT_ALL", function() {
              col.selection = null;
              });
            }
            
            
            main();
            

             

            More infos here:

            Programmation événementielle en ExtendScript | Ozalto

            • 3. Re: Linking multi column list selections in ScriptUI
              jakec88782761 Level 1

              That script worked great thanks so much Ariel! I don't suppose you know how I would use the sort() method on my list? It doesn't seem to work.