GtkCombo

GtkCombo

Text entry field with a dropdown list.

Object Hierarchy

GtkObject
`-- GtkWidget
       `-- GtkContainer
              `-- GtkBox
                     `-- GtkHBox
                            `-- GtkCombo

Direct subclasses

None.

Description

A GtkCombo appears to be the equivalent of the select element in HTML. This can be misleading if you're coming directly from a web development background; a GUI widget is largely about appearance, and carrying hidden values is not something this one will do without a little programming. Luckily, there are a trio of invaluable GtkObject methods that will do just that, with any object and with any form of data. These are get_data() , set_data() and remove_data() . See the sample under GtkCombo's constructor to get an idea of their usage.

There are a few key bindings in the combo widget. Most of them have some bearing on searches.

Table 1. Key bindings in GtkCombo

Key combinationFunction
Return (from the entry box) Opens up the list. If the entry contains text that fully matches a list item's content, that list item will be selected on opening.
Tab + MOD_1 mask (from the entry box) The MOD_1 modifier is usually Alt. This key combination auto-completes a partial entry.
Arrow up (from the entry box) If use_arrows has been set to true, scrolls up through the list without opening the list window. Can also be achieved with keypad arrow or Alt + p.
Arrow down (from the entry box) If use_arrows has been set to true, scrolls down through the list without opening the list window. Can also be achieved with keypad arrow or Alt + n.
Return (from the list box) Toggles the list item that has current focus.
Spacebar (from the list box) Selects the list item that has current focus.
Up arrow (from the list box) Scrolls up through the list items.
Down arrow (from the list box) Scrolls down through the list items.
Esc (from the list box) Removes grab from the list box, which closes it.

The normal but annoying behaviour is that the first entry is selected when you open the dropdown. This can be stopped by doing the following:
$objList = $objCombobox->list;
$objList->set_selection_mode( GTK_SELECTION_SINGLE);

See also: GtkEditable, GtkEntry, GtkItem, GtkList, GtkListItem, GtkOptionMenu.

GtkCombo has been deprecated since GTK+ 2.0 and should not be used in newly written code.

Constructor

GtkCombo (void);
-- Creates an entry box with a dropdown list.

Methods

set_value_in_list()
  Toggles whether entry value must be matched in list.
set_use_arrows()
  Toggles whether list can be scrolled within entry box.
set_use_arrows_always()
  Toggles whether entry box list-scrolling should loop.
set_case_sensitive()
  Toggles whether matching should be case-sensitive.
set_item_string()
  Sets string associated with list item.
set_popdown_strings()
  Simple list construction.
disable_activate()
  Prevents return key from opening dropdown list.

Properties

entry:
  Text entry field.
list:
  Dropdown list.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.