ComboBoxTextProtocol
public protocol ComboBoxTextProtocol : ComboBoxProtocol
A GtkComboBoxText
is a simple variant of GtkComboBox
for text-only
use cases.
GtkComboBoxText
hides the model-view complexity of GtkComboBox
.
To create a GtkComboBoxText
, use [ctorGtk.ComboBoxText.new
] or
[ctorGtk.ComboBoxText.new_with_entry
].
You can add items to a GtkComboBoxText
with
[methodGtk.ComboBoxText.append_text
],
[methodGtk.ComboBoxText.insert_text
] or
[methodGtk.ComboBoxText.prepend_text
] and remove options with
[methodGtk.ComboBoxText.remove
].
If the GtkComboBoxText
contains an entry (via the
[propertyGtk.ComboBox:has-entry
] property), its contents can be retrieved
using [methodGtk.ComboBoxText.get_active_text
].
You should not call [methodGtk.ComboBox.set_model
] or attempt to pack more
cells into this combo box via its [ifaceGtk.CellLayout
] interface.
GtkComboBoxText as GtkBuildable
The GtkComboBoxText
implementation of the GtkBuildable
interface supports
adding items directly using the <items> element and specifying <item>
elements for each item. Each <item> element can specify the “id”
corresponding to the appended text and also supports the regular
translation attributes “translatable”, “context” and “comments”.
Here is a UI definition fragment specifying GtkComboBoxText
items:
<object class="GtkComboBoxText">
<items>
<item translatable="yes" id="factory">Factory</item>
<item translatable="yes" id="home">Home</item>
<item translatable="yes" id="subway">Subway</item>
</items>
</object>
CSS nodes
combobox
╰── box.linked
├── entry.combo
├── button.combo
╰── window.popup
GtkComboBoxText
has a single CSS node with name combobox. It adds
the style class .combo to the main CSS nodes of its entry and button
children, and the .linked class to the node of its internal box.
The ComboBoxTextProtocol
protocol exposes the methods and properties of an underlying GtkComboBoxText
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 ComboBoxText
.
Alternatively, use ComboBoxTextRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkComboBoxText
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
combo_box_text_ptr
Default implementationTyped pointer to the underlying
GtkComboBoxText
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkComboBoxText
instance.Declaration
Swift
var combo_box_text_ptr: UnsafeMutablePointer<GtkComboBoxText>! { get }
-
Required Initialiser for types conforming to
ComboBoxTextProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ComboBoxTextPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: ComboBoxTextPropertyName, 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 transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a ComboBoxText property
Declaration
Swift
@inlinable func get(property: ComboBoxTextPropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a ComboBoxText property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: ComboBoxTextPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
append(id:
Extension methodtext: ) Appends
text
to the list of strings stored incombo_box
.If
id
is non-nil
then it is used as the ID of the row.This is the same as calling [method
Gtk.ComboBoxText.insert
] with a position of -1.Declaration
Swift
@inlinable func append(id: UnsafePointer<CChar>? = nil, text: UnsafePointer<CChar>!)
-
append(text:
Extension method) Appends
text
to the list of strings stored incombo_box
.This is the same as calling [method
Gtk.ComboBoxText.insert_text
] with a position of -1.Declaration
Swift
@inlinable func append(text: UnsafePointer<CChar>!)
-
getActiveText()
Extension methodReturns the currently active string in
combo_box
.If no row is currently selected,
nil
is returned. Ifcombo_box
contains an entry, this function will return its contents (which will not necessarily be an item from the list).Declaration
Swift
@inlinable func getActiveText() -> String!
-
insert(position:
Extension methodid: text: ) Inserts
text
atposition
in the list of strings stored incombo_box
.If
id
is non-nil
then it is used as the ID of the row. See [propertyGtk.ComboBox:id-column
].If
position
is negative thentext
is appended.Declaration
Swift
@inlinable func insert(position: Int, id: UnsafePointer<CChar>? = nil, text: UnsafePointer<CChar>!)
-
insertText(position:
Extension methodtext: ) Inserts
text
atposition
in the list of strings stored incombo_box
.If
position
is negative thentext
is appended.This is the same as calling [method
Gtk.ComboBoxText.insert
] with anil
ID string.Declaration
Swift
@inlinable func insertText(position: Int, text: UnsafePointer<CChar>!)
-
prepend(id:
Extension methodtext: ) Prepends
text
to the list of strings stored incombo_box
.If
id
is non-nil
then it is used as the ID of the row.This is the same as calling [method
Gtk.ComboBoxText.insert
] with a position of 0.Declaration
Swift
@inlinable func prepend(id: UnsafePointer<CChar>? = nil, text: UnsafePointer<CChar>!)
-
prepend(text:
Extension method) Prepends
text
to the list of strings stored incombo_box
.This is the same as calling [method
Gtk.ComboBoxText.insert_text
] with a position of 0.Declaration
Swift
@inlinable func prepend(text: UnsafePointer<CChar>!)
-
remove(position:
Extension method) Removes the string at
position
fromcombo_box
.Declaration
Swift
@inlinable func remove(position: Int)
-
removeAll()
Extension methodRemoves all the text entries from the combo box.
Declaration
Swift
@inlinable func removeAll()
-
activeText
Extension methodReturns the currently active string in
combo_box
.If no row is currently selected,
nil
is returned. Ifcombo_box
contains an entry, this function will return its contents (which will not necessarily be an item from the list).Declaration
Swift
@inlinable var activeText: String! { get }