Skip to main content
Participating Frequently
August 12, 2024
Question

Dropdown With Scrollbar

  • August 12, 2024
  • 2 replies
  • 575 views

Hello!

I have a dowpdownlist  with very many items, and I would like to show it with scollbars instead of a very long list.. I've read about the maximumSize property, but it do not seem to apply... Does someone know how to handle it or to add a scrollbar?

 

var myWin = new Window('dialog', 'My Long List');
myWin.orientation = 'column';
	with(myWin){
	myWin.sText = add('statictext', undefined, 'Select From List:');
	myWin.myFontDrop = add('dropdownlist',undefined,undefined,{items:myLongList,);
	myWin.myFontDrop.selection = 0;
	myWin.btnOK = add('button', undefined, 'OK');
	}
myWin.center();

 

This topic has been closed for replies.

2 replies

Peter Kahrel
Community Expert
Community Expert
August 12, 2024

The maximumSize property of dropdownlist applies to the control itself, not to the height of the list. You can see that when you use preferredSize, e.g. myWin.myFontDrop.preferredSize.height = 200;

 

If you want to control the number of displayed items you'll have to use a listbox, as Mark suggested. You can read about filtering listboxes in this PDF:

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

on pp. 37-39

viktor_nAuthor
Participating Frequently
August 12, 2024

Ah.. thanks @Peter Kahrel , I will try!

viktor_nAuthor
Participating Frequently
August 13, 2024

... so I check the listboxes element, but in the end this is not what I have in mind (UI-wise). It really seems that there is no way to influence the height of the list in a dropdownlist element ... but it also seems to be a questions that just comes out every few years ... 😕😕

m1b
Community Expert
Community Expert
August 12, 2024

Hi @viktor_n, I doubt that you can control this. I think the maximumSize and the preferredSize properties only affect the size of the non-activated dropdown (ie. the control before you click on it, before you invoke the menu). Maybe someone who knows more than me can help, but my guess is that we have no control over the menu display itself via the API. @Peter Kahrel is very knowledgable on ScriptUI.

 

Another option could be to use a Listbox? A ListBox with a filter field might be a good solution to a long font list.

- Mark

viktor_nAuthor
Participating Frequently
August 12, 2024

Thanks @m1b , no matter I use a listbox ot a dropdownlist, if I try to apply size or maximumSize, I always get an empty element with no content ... it seems something wrong the way I try to apply it ...

myWin.myFontDrop = add('listbox {properties: {size: [400,800]}}',undefined,undefined,{items:myLongList});



Peter Kahrel
Community Expert
Community Expert
August 12, 2024

(Unnecessary blabbering removed)