Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I script a dialog box to display information?

Explorer ,
May 15, 2016 May 15, 2016

Hi, there.

I would like to script a dialog box that contains 7 rows and 2 collumns in which to display info as such:

How do I do that?

Any help would be appreciated.

TOPICS
Scripting
707
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , May 16, 2016 May 16, 2016

ScriptUI doesnt have tables, the closer you can get is using a listbox. Depending on the version of your app, the lines will be drawn or not but i dont think you can control it.

var w = new Window("dialog", "test");

var lb = w.add("listbox{properties: {multiselect: false, numberOfColumns: 2, columnWidths: [60,60], columnTitles: ['A', 'B'], showHeaders: false}}");

for (var k=1; k<8; k++){

    lb.add("item", (5*k).toString()).subItems[0].text = (11*(k+1)).toString();

    };

w.show();

You can play around

...
Translate
Advocate ,
May 16, 2016 May 16, 2016

ScriptUI doesnt have tables, the closer you can get is using a listbox. Depending on the version of your app, the lines will be drawn or not but i dont think you can control it.

var w = new Window("dialog", "test");

var lb = w.add("listbox{properties: {multiselect: false, numberOfColumns: 2, columnWidths: [60,60], columnTitles: ['A', 'B'], showHeaders: false}}");

for (var k=1; k<8; k++){

    lb.add("item", (5*k).toString()).subItems[0].text = (11*(k+1)).toString();

    };

w.show();

You can play around with the creation properties.

For me, if showHeaders is true, the columnTitles are displayed and the columnWidths are respected.

But if it is false, the columnTitles are not displayed (as one would expect) but the columnWidths are not respected...

Xavier

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 16, 2016 May 16, 2016

How can I make the text "selectable"?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 16, 2016 May 16, 2016

Multi-column lists are certainly good for mimicking tables. Another possibility is to place edittextboxes very close to each other:

w = new Window ('dialog {orientation: "row", spacing: 0}');

  column1 = [];

  group1 = w.add ('group {orientation: "column", spacing: 0}');

  for (i = 0; i < 7; i++) {

    column1.push (group1.add ('edittext {preferredSize: [60,40], justify: "center"}'));

  }

 

  column2 = [];

  group2 = w.add ('group {orientation: "column", spacing: 0}');

  for (i = 0; i < 7; i++) {

    column2.push (group2.add ('edittext {preferredSize: [60,40], justify: "center"}'));

  }

 

  for (i = 0; i < 7; i++) {

    column1.text = String ((i+1)*5);

  }

  for (i = 0; i < 7; i++) {

    column2.text = (i+2)*11

  }

  column1[0].active = true;

 

w.show();

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 17, 2016 May 17, 2016
LATEST

In a listbox, only whole rows can be selected, not individual slots (items/subItems), and the content of slots cannot be edited directly.

So Peter's solution seems more appropriate if you want to give the user the possibility to select individual slots and eventually edit them.

Xavier.

And i forgot to say in the first post that creation properties in listboxes are all optionnal (for instance you dont need to specify the columnWidths, in which case ScriptUI determines them to fit best).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines