ComboBoxRef

public struct ComboBoxRef : ComboBoxProtocol, GWeakCapturing

A GtkComboBox is a widget that allows the user to choose from a list of valid choices. The GtkComboBox displays the selected choice. When activated, the GtkComboBox displays a popup which allows the user to make a new choice. The style in which the selected value is displayed, and the style of the popup is determined by the current theme. It may be similar to a Windows-style combo box.

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 GtkCellLayout 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 “has-entry” property allows the GtkComboBox to contain a GtkEntry. This entry can be accessed by calling gtk_bin_get_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, GtkComboBoxText offers a simple alternative. Both GtkComboBox and GtkComboBoxText can contain an entry.

CSS nodes

(plain Language Example):

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.

(plain Language Example):

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.

The ComboBoxRef type acts as a lightweight Swift reference to an underlying GtkComboBox instance. It exposes methods that can operate on this data type through ComboBoxProtocol conformance. Use ComboBoxRef only as an unowned reference to an existing GtkComboBox instance.

  • ptr
    Untyped pointer to the underlying `GtkComboBox` instance.
    

    For type-safe access, use the generated, typed pointer combo_box_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!

ComboBox Class