Personal COMBO BOX problem with keybord keys in popup wondow
I'm trying to build i new combo with 2 columns in list.
So I've used a gtkentry in a main window witha button to open a list
the list is into a popup window without decorations
The list is opened with button and then I would choose the row with
cursor keys but I'm not able to use the keyboard
Anyone can help me?
<?php
$window = &new GtkWindow();
$window->connect_simple('destroy', array( 'Gtk', 'main_quit'));
$window->set_size_request(-1,-1);
$window->add($vbox = new GtkVBox());
// the initial selection
$list = array('item 1', 'item 2', 'item 3', 'item 4');
$vbox->pack_start($hbox=new GtkHBox(), 0, 0);
$hbox->pack_start($label= new GtkLabel('Select: '), 0, 0);
$hbox->pack_start($entry = new GtkEntry(), 0, 0);
$hbox->pack_start($button = new GtkButton('V'), 0, 0);
$button->set_size_request(18,18);
$button->connect('clicked', "on_button");
//========================================================================
function on_button($button) { // process button click
global $window, $entry;
// == ENTRY POSITION
$win_pos=$window->get_position();
$x_field_pos=$entry->allocation->x;
$y_field_pos=$entry->allocation->y;
$x_shift=4;
$y_shift=23+$entry->allocation->height;
$x_win=$win_pos[0]+$x_field_pos+$x_shift;
$y_win=$win_pos[1]+$y_field_pos+$y_shift;
//==============================================
// CREO LA FINESTRA
$sub_list = &new GtkWindow(Gtk::WINDOW_POPUP);
$sub_list ->set_size_request(400,250);
$sub_list ->set_uposition($x_win,$y_win);
$sub_list ->set_modal(true);
$sub_list ->set_transient_for($window);
//=========================================
$sub_list->add($vbox = new GtkVBox());
// Set up a scroll window
$scrolled_win = new GtkScrolledWindow();
$scrolled_win->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
$vbox->pack_start($scrolled_win);
// ==================================================
// INSERISCO IL GTKTREEVIEW NEL SCROLLED WINDOW
$data=array(
array("01","Ferro"),
array("02","Acciaio"),
array("03","Tungsteno"),
array("042","Rame"),
array("044","Piombo"),
array("05","Alluminio"),
array("06","Carbonio"),
array("07","Uranio"),
array("08","Cobalto"),
array("07","Plutonio"),
array("08","Ottone"),
array("09","Zama"),
array("10","Molibdeno"),
array("11","Bronzo"),
array("12","Oro"),
array("13","Argento"),
array("14","Platino"),
array("15","Berillio")
);
display_table($scrolled_win, $data);
// =================================================
$vbox->pack_start($button = new GtkButton('Chiudi'), 0, 0);
$button->connect('clicked', "on_destroy",$sub_list);
$sub_list ->show_all();
}
function display_table($scrolled_win, $data) {
// Creates the list store
$model = new GtkListStore(Gtk::TYPE_STRING, Gtk::TYPE_STRING); // note 2
$field_header = array('Row #', 'Description'); // note 3
// Creates the view to display the list store
$view = new GtkTreeView($model); // note 4
$scrolled_win->add($view); // note 5
// Creates columns
for ($col=0; $col<count($field_header); ++$col) {
$cell_renderer = new GtkCellRendererText();
$column = new GtkTreeViewColumn($field_header[$col], $cell_renderer, 'text', $col);
$view->append_column($column);
}
// pupulates the data
for ($row=0; $row<count($data); ++$row) {
$values = array();
for ($col=0; $col<count($data[$row]); ++$col) {
$values[] = $data[$row][$col];
}
$model->append($values); // note 6
}
}
function on_destroy($button,$obj) {
$obj->destroy();
}
$window->show_all();
Gtk::main();
?>