Gtk.ComboBoxText

const Gtk = imports.gi.Gtk;

let combo_box_text = new Gtk.ComboBoxText();
  

A GtkComboBoxText is a simple variant of Gtk.ComboBox that hides the model-view complexity for simple text-only use cases.

To create a GtkComboBoxText, use Gtk.new or Gtk.new_with_entry.

You can add items to a GtkComboBoxText with Gtk.append_text, Gtk.insert_text or Gtk.prepend_text and remove options with Gtk.remove.

If the GtkComboBoxText contains an entry (via the 'has-entry' property), its contents can be retrieved using Gtk.get_active_text. The entry itself can be accessed by calling Gtk.Bin.prototype.get_child on the combo box.

You should not call Gtk.ComboBox.prototype.set_model or attempt to pack more cells into this combo box via its GtkCellLayout interface.

<refsect2 id="GtkComboBoxText-BUILDER-UI"> <title>GtkComboBoxText as GtkBuildable</title> <para> The GtkComboBoxText implementation of the GtkBuildable interface supports adding items directly using the &lt;items&gt; element and specifying &lt;item&gt; elements for each item. Each &lt;item&gt; element can specify the "id" corresponding to the appended text and also supports the regular translation attributes "translatable", "context" and "comments".

<example> <title>A UI definition fragment specifying GtkComboBoxText items</title> <programlisting><![CDATA[ <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> ]]></programlisting> </example> </para> </refsect2>

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gtk.Widget
        • Gtk.Container
          • Gtk.Bin
            • Gtk.ComboBox
              • Gtk.ComboBoxText