ComboBox

open class ComboBox : Bin, ComboBoxProtocol

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 ComboBox type acts as a reference-counted owner of an underlying GtkComboBox instance. It provides the methods that can operate on this data type through ComboBoxProtocol conformance. Use ComboBox as a strong reference or owner of a GtkComboBox instance.

  • Designated initialiser from the underlying `C` data type.
    

    This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the ComboBox instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafeMutablePointer<GtkComboBox>)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the ComboBox instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafePointer<GtkComboBox>)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a non-mutating gpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the ComboBox instance.

    Declaration

    Swift

    @inlinable
    override public init!(gpointer op: gpointer?)

    Parameters

    op

    gpointer to the underlying object

  • Optional initialiser from a non-mutating gconstpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the ComboBox instance.

    Declaration

    Swift

    @inlinable
    override public init!(gconstpointer op: gconstpointer?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the ComboBox instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafePointer<GtkComboBox>?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the ComboBox instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafeMutablePointer<GtkComboBox>?)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from the underlying C data type. Will retain GtkComboBox. i.e., ownership is transferred to the ComboBox instance.

    Declaration

    Swift

    @inlinable
    public init(retaining op: UnsafeMutablePointer<GtkComboBox>)

    Parameters

    op

    pointer to the underlying object

  • Reference intialiser for a related type that implements ComboBoxProtocol Will retain GtkComboBox.

    Declaration

    Swift

    @inlinable
    public init<T>(comboBox other: T) where T : ComboBoxProtocol

    Parameters

    other

    an instance of a related type that implements ComboBoxProtocol

  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ComboBoxProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(cPointer p: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ComboBoxProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ComboBoxProtocol.

    Declaration

    Swift

    @inlinable
    override public init(raw p: UnsafeRawPointer)

    Parameters

    p

    raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ComboBoxProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingRaw raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ComboBoxProtocol.

    Declaration

    Swift

    @inlinable
    public required init(raw p: UnsafeMutableRawPointer)

    Parameters

    p

    mutable raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ComboBoxProtocol.

    Declaration

    Swift

    @inlinable
    required public init(retainingRaw raw: UnsafeMutableRawPointer)

    Parameters

    raw

    mutable raw pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ComboBoxProtocol.

    Declaration

    Swift

    @inlinable
    override public init(opaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ComboBoxProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingOpaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Creates a new empty GtkComboBox.

    Declaration

    Swift

    @inlinable
    public init()
  • Creates a new empty GtkComboBox using area to layout cells.

    Declaration

    Swift

    @inlinable
    public init<CellAreaT>(area: CellAreaT) where CellAreaT : CellAreaProtocol
  • Creates a new empty GtkComboBox with an entry.

    The new combo box will use area to layout cells.

    Declaration

    Swift

    @inlinable
    public init<CellAreaT>(areaAndEntry area: CellAreaT) where CellAreaT : CellAreaProtocol
  • Creates a new GtkComboBox with the model initialized to model.

    Declaration

    Swift

    @inlinable
    public init<TreeModelT>(model: TreeModelT) where TreeModelT : TreeModelProtocol
  • Creates a new empty GtkComboBox with an entry and with the model initialized to model.

    Declaration

    Swift

    @inlinable
    public init<TreeModelT>(modelAndEntry model: TreeModelT) where TreeModelT : TreeModelProtocol
  • Creates a new empty GtkComboBox using area to layout cells.

    Declaration

    Swift

    @inlinable
    public static func newWith<CellAreaT>(area: CellAreaT) -> Widget! where CellAreaT : CellAreaProtocol
  • Creates a new empty GtkComboBox with an entry.

    The new combo box will use area to layout cells.

    Declaration

    Swift

    @inlinable
    public static func newWith<CellAreaT>(areaAndEntry area: CellAreaT) -> Widget! where CellAreaT : CellAreaProtocol
  • Creates a new empty GtkComboBox with an entry.

    Declaration

    Swift

    @inlinable
    public static func newWithEntry() -> Widget!
  • Creates a new GtkComboBox with the model initialized to model.

    Declaration

    Swift

    @inlinable
    public static func newWith<TreeModelT>(model: TreeModelT) -> Widget! where TreeModelT : TreeModelProtocol
  • Creates a new empty GtkComboBox with an entry and with the model initialized to model.

    Declaration

    Swift

    @inlinable
    public static func newWith<TreeModelT>(modelAndEntry model: TreeModelT) -> Widget! where TreeModelT : TreeModelProtocol