A question about droplists in G4P

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