Package: gtk

Class gtk:combo-box

Superclasses

Documented Subclasses

Direct Slots

active
The active property of type :int (Read / Write)
The item which is currently active. If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this property has the value (first (gtk:tree-path-indices path)), where path is the gtk:tree-path instance of the active item.
Allowed values: >= -1
Default value: -1
active-id
The active-id property of type :string (Read / Write)
The value of the ID column of the active row.
Default value: nil
button-sensitivity
The button-sensitivity property of type gtk:sensitivity-type (Read / Write)
Whether the dropdown button is sensitive when the model is empty.
Default value: :auto
child
The child property of type gtk:widget (Read / Write)
The child widget.
entry-text-column
The entry-text-column property of type :int (Read / Write)
The column in the model of the combo box to associate with strings from the entry if the combo box was created with the value true for the has-entry property.
Allowed values: >= -1
Default value: -1
has-entry
The has-entry property of type :boolean (Read / Write / Construct)
Whether the combo box has an entry.
Default value: false
has-frame
The has-frame property of type :boolean (Read / Write)
Controls whether a frame is drawn around the text entry.
Default value: true
id-column
The id-column property of type :int (Read / Write)
The column in the combo box's model that provides string IDs for the values in the model, if not equal to -1.
Allowed values: >= -1
Default value: -1
model
The model property of type gtk:tree-model (Read / Write)
The model from which the combo box takes the values shown in the list.
popup-fixed-width
The popup-fixed-width property of type :boolean (Read / Write)
Whether the popup's width should be a fixed width matching the allocated width of the combo box.
Default value: true
popup-shown
The popup-shown property of type :boolean (Read)
Whether the combo boxes dropdown is popped up. Note that this property is mainly useful, because it allows you to connect to the "notify::popup-shown" signal.
Default value: false

Details

The gtk:combo-box widget allows the user to choose from a list of valid choices. The gtk:combo-box widget displays the selected choice. When activated, the gtk:combo-box widget 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 gtk:combo-box widget 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 the gtk:combo-box class implements the gtk:cell-layout 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 gtk:combo-box widget to contain a gtk:entry widget. This entry can be accessed by calling the gtk:combo-box-child function on the combo box.

For a simple list of textual choices, the model-view API of the gtk:combo-box widget can be a bit overwhelming. In this case, the gtk:combo-box-text widget offers a simple alternative. Both the gtk:combo-box widget and the gtk:combo-box-text widget can contain an entry.

CSS nodes

 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 gtk:combo-box widget 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

The gtk:combo-box implementation uses the :combo-box role of the gtk:accessible-role enumeration.

Warning

The gtk:combo-box implementation is deprecated since 4.10. Use the gtk:drop-down widget instead.

Signal Details

The "activate" signal
lambda (combo)    :action      
combo
The gtk:combo-box widget that received the signal.
Emitted to when the combo box is activated. The signal is an action signal and emitting it causes the combo box to pop up its dropdown. Since 4.6
The "changed" signal
lambda (combo)    :run-last      
combo
The gtk:combo-box widget that received the signal.
The signal is emitted when the active item is changed. The can be due to the user selecting a different item from the list, or due to a call to the gtk:combo-box-active-iter function. It will also be emitted while typing into the text entry of a combo box with an entry.
The "format-entry-text" signal
lambda (combo pathstr)    :run-last      
combo
The gtk:combo-box widget that received the signal.
pathstr
The string representing the gtk:tree-path instance from the combo box's current model to format text for.
Returns
The string representing the value at pathstr for the current gtk:combo-box model.
A signal which allows you to change how the text displayed in a entry of the combo box is displayed. Connect a signal handler which returns an allocated string representing path. That string will then be used to set the text in the text entry of the combo box. The default signal handler uses the text from the entry-text-column property model column. Here is an example signal handler which fetches data from the model and displays it in the text entry. For combo boxes that are created with a text entry. See the has-entry property.
(defun format-entry-text-callback (combo pathstr)
  (let* ((model (gtk:combo-box-model combo))
         (iter (gtk:tree-model-iter-from-string model pathstr))
         (value (gtk:tree-model-value model iter col-value)))
    (format nil "~a" value)))      
The "move-active" signal
lambda (combo scroll)    :action      
combo
The gtk:combo-box widget that received the signal.
scroll
The value of the gtk:scroll-type enumeration.
A keybinding signal which gets emitted to move the active selection.
The "popdown" signal
lambda (combo)    :action      
combo
The gtk:combo-box widget that received the signal.
A keybinding signal which gets emitted to popdown the combo box list. The default bindings for this signal are the Alt+Up and Escape keys.
The "popup" signal
lambda (combo)    :action      
combo
The gtk:combo-box widget that received the signal.
A keybinding signal which gets emitted to popup the combo box list. The default binding for this signal is the Alt+Down key.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2024-4-7