A question about droplists in G4P

I have a question about the expected behaviour of droplists in G4P. When you create a droplist, you can optionally specify a maximum size (ie, number of items in the list). I want to build several droplists dynamically (lists of MIDI input and output devices, lists of audio input and output devices, lists of other computers on the LAN). So I won’t know in advance how long the lists will be. What happens if the length of the constructed list exceeds the maximum? It appears that it gets truncated to the maximum length. But what happens if I don’t specify a maximum? Will the list get resized automatically, if required? Or would it be better to specify a maximum, test myself to see if the maximum has been exceeded, and recreate the droplist with a new maximum?

Also, I’m trying to understand how the maximum size parameter relates to the vertical height parameter of the droplist. Should the height be the height of a single row, or the total height when the list is displayed? It seems that if I specify a really large number for the maximum, the rows get “squished together”, so to speak, and aren’t very legible.

1 Like

When you create any visual G4P control you have to specify the width and height of the control because internally it creates a graphic buffer for the control image and after the draw() method is executed G4P copies the internal buffers to the display.

In the case of GDropList the size must also include space for the drop list when active. In the GDropList constructor you have the option of specifying the maximum number of items to show in the drop list,. If you don’t specify a value G4P will assume a maximum of 4, once you have created the GDropList you cannot change the maximum list size.

IMPORTANT

  • There is no limit to the number of items in your list just the maximum number that can be shown at a time.
  • If there are more items in the list than the maximum then a scrollbar will appear and you can scroll up/down the list and select the one you want.
  • If there are less it will reduce the visual size of the droplist to accordingly.

The important thing factor is the maximum number of items in the drop list to show when active, if you call that n then overall height of the control should be about 20(n + 1) this would give each list item a vertical height of 20 pixels.

HTH

2 Likes