ComboBox

A button that, when clicked, opens a popup to select a value.

Properties

  • current_index: (in_out int): The index of the selected value (-1 if no value is selected)
  • current_value: (out ListViewItem): The currently selected text
  • enabled: (in bool): Defaults to true. When false, the combobox can't be interacted with
  • has_focus: (out bool): Set to true when the combobox has keyboard focus.
  • model (in [ListViewItem]): The model of items.
  • placeholder_text: (in string): A placeholder text being shown when there is no item selected

Callbacks

  • selected(/* current_index */ int): A value was selected from the combo box. The argument is the currently selected value.

Example

import { ComboBox } from "@coop/lib.slint";

export component Example inherits Window {
    width: 200px;
    height: 130px;

    ComboBox {
        y: 0px;
        width: self.preferred_width;
        height: self.preferred_height;
        model: [
            {
                text: "Item one"
            },
            {
                text: "Item three"
            },
            {
                text: "Item four"
            }
        ];
    }
}