Gtk2::Ex::ComboBox::Text -- text combobox with "active-text" property


 use Gtk2::Ex::ComboBox::Text;
 my $combo = Gtk2::Ex::ComboBox::Text->new_text;
 $combo->append_text ('First Choice');
 $combo->append_text ('Second Choice');

 $combo->set (active_text => 'Second Choice');


Gtk2::Ex::ComboBox::Text is a subclass of Gtk2::ComboBox,



This is a "text" style convenience Gtk2::ComboBox with the addition of an active-text property, and a couple of pseudo-properties to help filling in the choices.

    | Text One  |

The active-text property is the same as $combo->get_active_text but as a property can be treated a bit more generally than a method call, for instance link it up to another widget with Glib::Ex::ConnectProperties.


$combobox = Gtk2::Ex::ComboBox::Text->new (key => value,...)
$combobox = Gtk2::Ex::ComboBox::Text->new_text (key => value,...)

Create and return a new Text combobox object. new and new_text are the same thing, since a Text combobox is always text style. Optional key/value pairs set initial properties per Glib::Object->new.

    my $combo = Gtk2::Ex::ComboBox::Text->new;
$combobox->set_active_text ($str)

The choice $str active, the same as setting the active-text property.

It's slightly unspecified as yet what happens if $str is not available as a choice in $combobox.


active-text (string or undef, default undef)

The text of the selected item, or undef if nothing selected.

append-text (string, write-only)
prepend-text (string, write-only)

Write-only pseudo-properties which add text choices to the combobox as per the usual append_text and prepend_text methods.


Gtk2::Ex::ComboBox::Text inherits the usual buildable support from Gtk2::ComboBox, allowing Gtk2::Builder (new in Gtk 2.12) to construct a Text combobox. The class name is Gtk2__Ex__ComboBox__Text and properties and signal handlers can be set in the usual way.

The append-text property is a good way to add choices to the combobox from within the builder specification. Either active or active-text can set an initial selection. Here's a sample fragment, or see examples/ in the ComboBoxBits sources for a complete program.

    <object class="Gtk2__Ex__ComboBox__Text" id="combo">
      <property name="append-text">First Choice</property>
      <property name="append-text">Second Choice</property>
      <property name="active">0</property>


Gtk2::ComboBox, Gtk2::Ex::ComboBoxBits, Gtk2::Ex::ComboBox::Enum



Copyright 2010, 2011 Kevin Ryde

Gtk2-Ex-ComboBoxBits is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Gtk2-Ex-ComboBoxBits is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Gtk2-Ex-ComboBoxBits. If not, see