ComboBox


Object Hierarchy:

Gtk.ComboBox Gtk.ComboBox Gtk.ComboBox Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.ComboBox GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Gtk.Accessible Gtk.Accessible Gtk.Accessible->Gtk.ComboBox Gtk.Accessible->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.ComboBox Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget Gtk.ConstraintTarget Gtk.ConstraintTarget->Gtk.ComboBox Gtk.ConstraintTarget->Gtk.Widget Gtk.CellEditable Gtk.CellEditable Gtk.CellEditable->Gtk.ComboBox Gtk.CellLayout Gtk.CellLayout Gtk.CellLayout->Gtk.ComboBox

Description:

[ CCode ( type_id = "gtk_combo_box_get_type ()" ) ]
public class ComboBox : Widget, Accessible, Buildable, CellEditable, CellLayout, ConstraintTarget

A `GtkComboBox` is a widget that allows the user to choose from a list of valid choices.

![An example GtkComboBox](combo-box.png)

The `GtkComboBox` displays the selected choice; when activated, the `GtkComboBox` displays a popup which allows the user to make a new choice.

The `GtkComboBox` uses the model-view pattern; the list of valid choices is specified in the form of a tree model, and the display of the choices can be adapted to the data in the model by using cell renderers, as you would in a tree view. This is possible since `GtkComboBox` implements the [[email protected]] interface. The tree model holding the valid choices is not restricted to a flat list, it can be a real tree, and the popup will reflect the tree structure.

To allow the user to enter values not in the model, the [[email protected]:has-entry] property allows the `GtkComboBox` to contain a [[email protected]]. This entry can be accessed by calling [[email protected]_child] on the combo box.

For a simple list of textual choices, the model-view API of `GtkComboBox` can be a bit overwhelming. In this case, [ [email protected]] offers a simple alternative. Both `GtkComboBox` and `GtkComboBoxText` can contain an entry.

CSS nodes

``` combobox ├── box.linked │ ╰── button.combo │ ╰── box │ ├── cellview │ ╰── arrow ╰── window.popup ```

A normal combobox contains a box with the .linked class, a button with the .combo class and inside those buttons, there are a cellview and an arrow.

``` combobox ├── box.linked │ ├── entry.combo │ ╰── button.combo │ ╰── box │ ╰── arrow ╰── window.popup ```

A `GtkComboBox` with an entry has a single CSS node with name combobox. It contains a box with the .linked class. That box contains an entry and a button, both with the .combo class added. The button also contains another node with name arrow.

Accessibility

`GtkComboBox` uses the gtk_accessible_role_combo_box role.

All known sub-classes:

Namespace: Gtk
Package: gtk4

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from class GLib.Object
All known members inherited from interface Gtk.CellEditable



2022 vala-language.org