Skip to main content
deckarduk
Inspiring
May 30, 2023
Answered

InDesign Javascript - Resizeable listbox question...

  • May 30, 2023
  • 4 replies
  • 936 views

Hi everyone,

I have been looking at properties of a listBox, the ESTK script examples and the ScriptUI guide, but as yet haven't found an answer.

Is it possible to make a listBox resizeable as you would say with a palette? So if the user resizes the palette the listBox would resize accordingly.

Thanks.

 

This topic has been closed for replies.
Correct answer Peter Kahrel

A variant of an example in https://creativepro.com/files/kahrel/indesign/scriptui.html, p. 106:

 

var w = new Window ('dialog', 'Resize', undefined, {resizeable: true});
  w.orientation = 'row';

  w.box = w.add ('listbox', undefined, ['a', 'b', 'c', 'd'])
    w.box.alignment = ['fill', 'fill'];
    w.box.minimumSize = [200, 100];

  w.buttons = w.add ('group {orientation: "column"}');
    w.buttons.alignment = ['right', 'top'];
    w.buttons.alignChildren = 'fill';

    w.buttons.add ('button {text: "This"}');
    w.buttons.add ('button {text: "That"}');
    w.buttons.add ('button {text: "And the other"}');

  // onResize needed on Mac OS X

  w.onResizing = w.onResize = function () {
    this.layout.resize ();
  }
  
  w.onShow = function () {
    w.minimumSize = w.size;
  }

w.show ();

4 replies

Peter Kahrel
Community Expert
Community Expert
June 2, 2023

Can you think of a reason why the radio buttons and buttons don't appear initially?

 

Not really. ScriptUI is buggy, and unfortunately receives little or no attention from Adobe. Most if not all of the engineering effort is aimed at UXP (understandably).

 

The interface you describe sounds as if it has a lot in common with this script:

https://creativepro.com/files/kahrel/indesign/grep_query_manager.html

a multi-column listbox in a resizable window with various checkboxes and buttons.

 

In that script, when the window is first drwan, I have this code:

w.onShow = function () {
  w.layout.layout();
  w.minimumSize.height = buttons.size[1];
  . . .
}

It's been a while, but I put those lines there probably to deal with the problem you described.

 

Even so, resizing is a bit of a mess: in the script (which no doubt could be improved in many ways) when you resize the window, you have to click on the window's bottom-right corner to update the window's layout.

 

P.

 

deckarduk
deckardukAuthor
Inspiring
June 5, 2023

Thanks for the help, and URL, Peter.

Wow! The GREP manager looks great, lovely palette layout.

I'll see if tweaking anything helps.

Thank you once again.

 

Peter Kahrel
Community Expert
Community Expert
May 31, 2023

Instread of w.box you could also say var box. Doesn't make much difference. Using w.box creates fewer variables and makes the script more efficient, if maybe only theoretically

.

 

 

 

deckarduk
deckardukAuthor
Inspiring
June 2, 2023

Hi Peter,

Thanks again for the help and furthering my knowledge that it further 👍

I have managed to apply the method above to the palette I have written.

Just need to stop a couple of panels expanding vertically but apart from that all seems to be working ok.

Thank you once again for your help 🙂

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
May 31, 2023

A variant of an example in https://creativepro.com/files/kahrel/indesign/scriptui.html, p. 106:

 

var w = new Window ('dialog', 'Resize', undefined, {resizeable: true});
  w.orientation = 'row';

  w.box = w.add ('listbox', undefined, ['a', 'b', 'c', 'd'])
    w.box.alignment = ['fill', 'fill'];
    w.box.minimumSize = [200, 100];

  w.buttons = w.add ('group {orientation: "column"}');
    w.buttons.alignment = ['right', 'top'];
    w.buttons.alignChildren = 'fill';

    w.buttons.add ('button {text: "This"}');
    w.buttons.add ('button {text: "That"}');
    w.buttons.add ('button {text: "And the other"}');

  // onResize needed on Mac OS X

  w.onResizing = w.onResize = function () {
    this.layout.resize ();
  }
  
  w.onShow = function () {
    w.minimumSize = w.size;
  }

w.show ();
deckarduk
deckardukAuthor
Inspiring
May 31, 2023

Hi Peter,

Thank you for the help 👍

Is it necessary to have the 'box' part in the code? For example...

w.box = w.add ('listbox', undefined, ['a', 'b', 'c', 'd'])

Is that an object linked to the new window?

deckarduk
deckardukAuthor
Inspiring
May 31, 2023

Thanks for the help 👍

I'd seen that post and have been able to get the palette to resize however, so far I've not been able to get the listBox to resize.