About my projects, examples and tutorials
Gnome::Gtk4::ComboBoxText

Gnome::Gtk4::ComboBoxText

Description§

A Gnome::Gtk4::ComboBoxText is a simple variant of Gnome::Gtk4::ComboBox for text-only use cases.

UNKNOWN image§

=for image :class<inline> :src<asset_files/images/combo-box-text.png> :width<30\%>

Gnome::Gtk4::ComboBoxText hides the model-view complexity of Gnome::Gtk4::ComboBox.

To create a Gnome::Gtk4::ComboBoxText, use .newcomboboxtext() or .new-with-entry().

You can add items to a Gnome::Gtk4::ComboBoxText with .append-text(), .insert-text() or .prepend-text() and remove options with .remove().

If the Gnome::Gtk4::ComboBoxText contains an entry (via the has-entry defined in Gnome::Gtk4::ComboBox property), its contents can be retrieved using .get-active-text().

You should not call .set-model() in class ComboBox or attempt to pack more cells into this combo box via its /content-docs/api2/reference/Gnome::Gtk4::R-CellLayout interface.

GtkComboBoxText as GtkBuildable§

The Gnome::Gtk4::ComboBoxText implementation of the Gnome::Gtk4::R-Buildable 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 Gnome::Gtk4::ComboBoxText items:

CSS nodes§

Gnome::Gtk4::ComboBoxText 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.

Uml Diagram§

UNKNOWN image§

=for image :class<inline> :src<asset_files/images/plantuml/ComboBoxText.png> :width<70\%>

Class initialization§

Note: The native version of this class is deprecated in gtk4-lib() since version 4.10

new§

:native-object§

Create an object using a native object from an object of the same type found elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object() :$native-object! )
Code

new-comboboxtext§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Creates a new Gnome::Gtk4::ComboBoxText.

method new-comboboxtext ( --> Gnome::Gtk4::ComboBoxText )
Code

new-with-entry§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Creates a new Gnome::Gtk4::ComboBoxText with an entry.

method new-with-entry ( --> Gnome::Gtk4::ComboBoxText )
Code

Methods§

append§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Appends $text to the list of strings stored in $combo-box.

If $id is non-undefined then it is used as the ID of the row.

This is the same as calling .insert() with a position of -1.

method append ( Str $id, Str $text )
Code
  • $id; a string ID for this value.
  • $text; A string.

append-text§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Appends $text to the list of strings stored in $combo-box.

This is the same as calling .insert-text() with a position of -1.

method append-text ( Str $text )
Code
  • $text; A string.

get-active-text§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Returns the currently active string in $combo-box.

If no row is currently selected, undefined is returned. If $combo-box contains an entry, this function will return its contents (which will not necessarily be an item from the list).

method get-active-text (--> Str )
Code

Return value; a newly allocated string containing the currently active text. Must be freed with g_free()..

insert§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Inserts $text at $position in the list of strings stored in $combo-box.

If $id is non-undefined then it is used as the ID of the row. See id-column defined in Gnome::Gtk4::ComboBox.

If $position is negative then $text is appended.

method insert ( Int() $position, Str $id, Str $text )
Code
  • $position; An index to insert $text.
  • $id; a string ID for this value.
  • $text; A string to display.

insert-text§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Inserts $text at $position in the list of strings stored in $combo-box.

If $position is negative then $text is appended.

This is the same as calling .insert() with a undefined ID string.

method insert-text ( Int() $position, Str $text )
Code
  • $position; An index to insert $text.
  • $text; A string.

prepend§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Prepends $text to the list of strings stored in $combo-box.

If $id is non-undefined then it is used as the ID of the row.

This is the same as calling .insert() with a position of 0.

method prepend ( Str $id, Str $text )
Code
  • $id; a string ID for this value.
  • $text; a string.

prepend-text§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Prepends $text to the list of strings stored in $combo-box.

This is the same as calling .insert-text() with a position of 0.

method prepend-text ( Str $text )
Code
  • $text; A string.

remove§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Removes the string at $position from $combo-box.

method remove ( Int() $position )
Code
  • $position; Index of the item to remove.

remove-all§

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Removes all the text entries from the combo box.

method remove-all ( )
Code