Package org.gnome.gtk

Class DropDown

java.lang.Object
All Implemented Interfaces:
Proxy, Accessible, Buildable, ConstraintTarget

@Generated("io.github.jwharm.JavaGI") public class DropDown extends Widget implements Accessible, Buildable, ConstraintTarget
GtkDropDown is a widget that allows the user to choose an item from a list of options.

An example GtkDropDown

The GtkDropDown displays the Gtk.DropDown:selected choice.

The options are given to GtkDropDown in the form of GListModel and how the individual options are represented is determined by a ListItemFactory. The default factory displays simple strings, and adds a checkmark to the selected item in the popup.

To set your own factory, use setFactory(org.gnome.gtk.ListItemFactory). It is possible to use a separate factory for the items in the popup, with setListFactory(org.gnome.gtk.ListItemFactory).

GtkDropDown knows how to obtain strings from the items in a StringList; for other models, you have to provide an expression to find the strings via setExpression(org.gnome.gtk.Expression).

GtkDropDown can optionally allow search in the popup, which is useful if the list of options is long. To enable the search entry, use setEnableSearch(boolean).

Here is a UI definition example for GtkDropDown with a simple model:

<object class="GtkDropDown">
   <property name="model">
     <object class="GtkStringList">
       <items>
         <item translatable="yes">Factory</item>
         <item translatable="yes">Home</item>
         <item translatable="yes">Subway</item>
       </items>
     </object>
   </property>
 </object>
 

If a GtkDropDown is created in this manner, or with fromStrings(java.lang.String[]), for instance, the object returned from getSelectedItem() will be a StringObject.

To learn more about the list widget framework, see the overview.

CSS nodes
GtkDropDown has a single CSS node with name dropdown, with the button and popover nodes as children.

Accessibility
GtkDropDown uses the AccessibleRole.COMBO_BOX role.