DropDown


Object Hierarchy:

Gtk.DropDown Gtk.DropDown Gtk.DropDown Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.DropDown GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Gtk.Accessible Gtk.Accessible Gtk.Accessible->Gtk.DropDown Gtk.Accessible->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.DropDown Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget Gtk.ConstraintTarget Gtk.ConstraintTarget->Gtk.DropDown Gtk.ConstraintTarget->Gtk.Widget

Description:

[ CCode ( type_id = "gtk_drop_down_get_type ()" ) ]
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.


Namespace: Gtk
Package: gtk4

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members:

All known members inherited from class Gtk.Widget