DropDownProtocol

public protocol DropDownProtocol : WidgetProtocol

GtkDropDown is a widget that allows the user to choose an item from a list of options.

An example GtkDropDown

The GtkDropDown displays the selected choice.

The options are given to GtkDropDown in the form of GListModel and how the individual options are represented is determined by a [classGtk.ListItemFactory]. The default factory displays simple strings.

GtkDropDown knows how to obtain strings from the items in a [classGtk.StringList]; for other models, you have to provide an expression to find the strings via [methodGtk.DropDown.set_expression].

GtkDropDown can optionally allow search in the popup, which is useful if the list of options is long. To enable the search entry, use [methodGtk.DropDown.set_enable_search].

CSS nodes

GtkDropDown has a single CSS node with name dropdown, with the button and popover nodes as children.

Accessibility

GtkDropDown uses the GTK_ACCESSIBLE_ROLE_COMBO_BOX role.

The DropDownProtocol protocol exposes the methods and properties of an underlying GtkDropDown instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see DropDown. Alternatively, use DropDownRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkDropDown instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • drop_down_ptr Default implementation

    Typed pointer to the underlying GtkDropDown instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkDropDown instance.

    Declaration

    Swift

    var drop_down_ptr: UnsafeMutablePointer<GtkDropDown>! { get }
  • Required Initialiser for types conforming to DropDownProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

DropDown Class

  • Bind a DropDownPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: DropDownPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a DropDown property

    Declaration

    Swift

    @inlinable
    func get(property: DropDownPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a DropDown property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: DropDownPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

DropDown Class: DropDownProtocol extension (methods and fields)

  • getEnableSearch() Extension method

    Returns whether search is enabled.

    Declaration

    Swift

    @inlinable
    func getEnableSearch() -> Bool
  • getExpression() Extension method

    Gets the expression set that is used to obtain strings from items.

    See [methodGtk.DropDown.set_expression].

    Declaration

    Swift

    @inlinable
    func getExpression() -> ExpressionRef!
  • getFactory() Extension method

    Gets the factory that’s currently used to populate list items.

    The factory returned by this function is always used for the item in the button. It is also used for items in the popup if [propertyGtk.DropDown:list-factory] is not set.

    Declaration

    Swift

    @inlinable
    func getFactory() -> ListItemFactoryRef!
  • getListFactory() Extension method

    Gets the factory that’s currently used to populate list items in the popup.

    Declaration

    Swift

    @inlinable
    func getListFactory() -> ListItemFactoryRef!
  • getModel() Extension method

    Gets the model that provides the displayed items.

    Declaration

    Swift

    @inlinable
    func getModel() -> GIO.ListModelRef!
  • getSelected() Extension method

    Gets the position of the selected item.

    Declaration

    Swift

    @inlinable
    func getSelected() -> Int
  • getSelectedItem() Extension method

    Gets the selected item. If no item is selected, nil is returned.

    Declaration

    Swift

    @inlinable
    func getSelectedItem() -> GLibObject.ObjectRef!
  • set(enableSearch:) Extension method

    Sets whether a search entry will be shown in the popup that allows to search for items in the list.

    Note that [propertyGtk.DropDown:expression] must be set for search to work.

    Declaration

    Swift

    @inlinable
    func set(enableSearch: Bool)
  • set(expression:) Extension method

    Sets the expression that gets evaluated to obtain strings from items.

    This is used for search in the popup. The expression must have a value type of G_TYPE_STRING.

    Declaration

    Swift

    @inlinable
    func set(expression: ExpressionRef? = nil)
  • set(expression:) Extension method

    Sets the expression that gets evaluated to obtain strings from items.

    This is used for search in the popup. The expression must have a value type of G_TYPE_STRING.

    Declaration

    Swift

    @inlinable
    func set<ExpressionT>(expression: ExpressionT?) where ExpressionT : ExpressionProtocol
  • set(factory:) Extension method

    Sets the GtkListItemFactory to use for populating list items.

    Declaration

    Swift

    @inlinable
    func set(factory: ListItemFactoryRef? = nil)
  • set(factory:) Extension method

    Sets the GtkListItemFactory to use for populating list items.

    Declaration

    Swift

    @inlinable
    func set<ListItemFactoryT>(factory: ListItemFactoryT?) where ListItemFactoryT : ListItemFactoryProtocol
  • setList(factory:) Extension method

    Sets the GtkListItemFactory to use for populating list items in the popup.

    Declaration

    Swift

    @inlinable
    func setList(factory: ListItemFactoryRef? = nil)
  • setList(factory:) Extension method

    Sets the GtkListItemFactory to use for populating list items in the popup.

    Declaration

    Swift

    @inlinable
    func setList<ListItemFactoryT>(factory: ListItemFactoryT?) where ListItemFactoryT : ListItemFactoryProtocol
  • set(model:) Extension method

    Sets the GListModel to use.

    Declaration

    Swift

    @inlinable
    func set(model: GIO.ListModelRef? = nil)
  • set(model:) Extension method

    Sets the GListModel to use.

    Declaration

    Swift

    @inlinable
    func set<ListModelT>(model: ListModelT?) where ListModelT : ListModelProtocol
  • setSelected(position:) Extension method

    Selects the item at the given position.

    Declaration

    Swift

    @inlinable
    func setSelected(position: Int)
  • enableSearch Extension method

    Returns whether search is enabled.

    Declaration

    Swift

    @inlinable
    var enableSearch: Bool { get nonmutating set }
  • expression Extension method

    An expression to evaluate to obtain strings to match against the search term.

    See [propertyGtk.DropDown:enable-search] for how to enable search. If [propertyGtk.DropDown:factory] is not set, the expression is also used to bind strings to labels produced by a default factory.

    Declaration

    Swift

    @inlinable
    var expression: ExpressionRef! { get nonmutating set }
  • factory Extension method

    Factory for populating list items.

    Declaration

    Swift

    @inlinable
    var factory: ListItemFactoryRef! { get nonmutating set }
  • listFactory Extension method

    Gets the factory that’s currently used to populate list items in the popup.

    Declaration

    Swift

    @inlinable
    var listFactory: ListItemFactoryRef! { get nonmutating set }
  • model Extension method

    Model for the displayed items.

    Declaration

    Swift

    @inlinable
    var model: GIO.ListModelRef! { get nonmutating set }
  • selected Extension method

    The position of the selected item.

    If no item is selected, the property has the value GTK_INVALID_LIST_POSITION.

    Declaration

    Swift

    @inlinable
    var selected: Int { get nonmutating set }
  • selectedItem Extension method

    Gets the selected item. If no item is selected, nil is returned.

    Declaration

    Swift

    @inlinable
    var selectedItem: GLibObject.ObjectRef! { get }