Skip to main content
Inspiring
April 7, 2016
Answered

ScriptUi listbox extending beyond window until resize

  • April 7, 2016
  • 2 replies
  • 978 views

I know this is not specifically about InDesign scripting but it will be incorporated into an InDesign script and InDesign scripters have a reputation as being the smartest!

What I am finding is when a listbox is larger than the window it extends beyond the window and is not reachable. If I apply a layout.resize() function to the window onResize event, the listbox fixes its self when I resize the window.

var w = new Window('dialog', undefined, undefined, {

        resizeable: true

    });

   

    w.orientation = 'row';

    w.alignChildren = 'top';

    w.maximumSize.height = 400;

   

    var myList = w.add ('listbox');

    myList.alignment = ['fill', 'fill'];

   

    var item;

    for (var i = 0; i < 200; i ++) {

        item = myList.add('Item', i);

        item.checked = true;

    }

   

    w.onResizing = w.onResize = function() {

        this.layout.resize();

    }

   

w.show ();

How do I make it so that the listbox fits within the window on show?

Also a second little issue: I am having troubles where the checks are not displaying when I scroll through them quickly. When I click on the item with the missing check marks they suddenly appear. This seems like a refresh issue. Is there something I can do to fix this as well?

This topic has been closed for replies.
Correct answer TᴀW

For the first issue, add an onShow event:

w.onShow = w.onResizing = w.onResize = function() {


I'm not able to reproduce the second issue, though.


Ariel





2 replies

Peter Kahrel
Community Expert
Community Expert
April 9, 2016

McShaman -- You should set the maximum size of the list, not the window.

Peter

TᴀW
TᴀWCorrect answer
Legend
April 8, 2016

For the first issue, add an onShow event:

w.onShow = w.onResizing = w.onResize = function() {


I'm not able to reproduce the second issue, though.


Ariel





id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
Loic.Aigon
Legend
April 8, 2016

I second Ariel. Adding handler to onShow event does the trick.