3 Replies Latest reply on Oct 2, 2012 12:24 PM by KuddRoww

    Column Widths - Script UI Problems

    KuddRoww Level 1

      Upon further review I realized that the method provided on page 28 of the Beginning Script Revision 1.9, January 2012 for creating a multi column listbox doesn't behave in application as it does in documentation.

       

      On the next page Peter provides a clearly superior method for creating multi column listboxes.

       

      However what I'd like to be able to do is create a multicolumn list box, with predefined column widths, where the column separator position can still be adjusted by the user. Is it possible to get this behaviour? A script illustrating the problematic behaviour is provided below, and below that is a capture image of the behaviour desired.

       

      Again any and all help with this matter is appreciated.

       

      var w = new Window ("dialog", "Tool",undefined,{});

      var panel2 = w.add ("panel");

      panel2.add ("statictext", undefined, "Results:");

      var resultsListbox = w.add ("listbox", undefined, undefined,

              {numberOfColumns: 2, showHeaders: true, columnTitles: ['Document', 'Keyword'], columnWidths: [100,100,100]});

              resultsListbox.minimumSize = [300,300]

       

       

      var myButtonGroup3 = panel2.add("group");

      var saveButton = myButtonGroup3.add ("button", undefined, "Save");

      var searchButton = myButtonGroup3.add ("button", undefined, "Search");

      var exitButton = myButtonGroup3.add ("button", undefined, "Exit");

      w.show();

       

       

       

      result.png

        • 1. Re: Column Widths - Script UI Problems
          Jump_Over Level 5

          Hi,

          my sugest is to include some items into your list (no items - no list )

           

          i.e.

          ....

          with (resultsListbox.add ("item", "1stDoc"))

          {

          subItems[0].text = "1stKey";

          }

          with (resultsListbox.add ("item", "2ndDoc"))

          {

          subItems[0].text = "2ndKey";

          }

          ...

           

          this should force columns to show with proper width, you set

           

          hope...

          • 2. Re: Column Widths - Script UI Problems
            Marc Autret Level 4

            Hi KuddRoww,

             

             

             

            You have two problems:

             

            (1) it looks like the columnWidths are not preprocessed as long as the listbox is empty;

            (2) a listbox has an "extra room" over the last column, but this extra room is not a column in itself and it's not easy to control its specific width.

             

            To solve (1) you just have to temporarily feed the list with a fake item, run the autolayout to get the columns sized, then remove the item.

            Solving (2) is not easy because the default extra space depends on the OS, but we can suppose it is around 18 pixels.

             

            Here is a possible starting point:

             

            var DESIRED_WIDTH = 300,
                COL1_WIDTH = 100,
                EXTRA_WIDTH = 18; // Depends on the OS
            
            var w = new Window ("dialog", "Tool",undefined,{});
            
            var panel2 = w.add ("panel");
            
            panel2.add ("statictext", undefined, "Results:");
            
            var resultsListbox = w.add ("listbox", undefined, [' '/*fake item*/],
                    {
                    numberOfColumns: 2,
                    showHeaders: true,
                    columnTitles: ['Document', 'Keyword'],
                    columnWidths: [COL1_WIDTH, DESIRED_WIDTH - COL1_WIDTH]
                    });
            
            resultsListbox.minimumSize = [1,DESIRED_WIDTH];
            
            var myButtonGroup3 = panel2.add("group");
            var saveButton = myButtonGroup3.add ("button", undefined, "Save");
            var searchButton = myButtonGroup3.add ("button", undefined, "Search");
            var exitButton = myButtonGroup3.add ("button", undefined, "Exit");
            
            // Pre-layout
            w.layout.layout(0);
            
            // Remove the fake item
            // ---
            resultsListbox.remove(0);
            
            // Fine-tuning
            // ---
            resultsListbox.maximumSize = [
                resultsListbox.size[0]-EXTRA_WIDTH,
                resultsListbox.maximumSize[1]
                ];
            
            w.show();
            

             

            @+

            Marc

            • 3. Re: Column Widths - Script UI Problems
              KuddRoww Level 1

              Thank-you two for your very helpful solutions!