DropDown
Object Hierarchy:
Description:
public sealed class DropDown : Widget, Accessible, Buildable, ConstraintTarget
`GtkDropDown` is a widget that allows the user to choose an item from a list of options.
![An example GtkDropDown](drop-down.png)
The `GtkDropDown` displays the selected choice.
The options are given to `GtkDropDown` in the form of `GListModel` and how the individual options are represented is determined by a [ class@Gtk.ListItemFactory]. The default factory displays simple strings, and adds a checkmark to the selected item in the popup.
To set your own factory, use [method@Gtk.DropDown.set_factory]. It is possible to use a separate factory for the items in the popup, with [ method@Gtk.DropDown.set_list_factory].
`GtkDropDown` knows how to obtain strings from the items in a [class@Gtk.StringList]; for other models, you have to provide an expression to find the strings via [method@Gtk.DropDown.set_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 [ method@Gtk.DropDown.set_enable_search].
Here is a UI definition example for `GtkDropDown` with a simple model:
```xml <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 [ctor@Gtk.DropDown.new_from_strings], for instance, the object returned from [ method@Gtk.DropDown.get_selected_item] will be a [class@Gtk.StringObject].
To learn more about the list widget framework, see the [overview](section-list-widget.html).
CSS nodes
`GtkDropDown` has a single CSS node with name dropdown, with the button and popover nodes as children.
Accessibility
`GtkDropDown` uses the gtk_accessible_role_combo_box role.