Re: Retrieve GtkCList Selection Info?
| From: | Tom Rogers | Date: | Thu, 04 Dec 2003 01:32:43 +0000 |
| Subject: | Re: Retrieve GtkCList Selection Info? | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-4276@lists.php.net to get a copy of this message | ||
Hi,
Thursday, December 4, 2003, 1:41:50 AM, you wrote:
LC> Hello,
LC> I've been working with a GtkCList and have been trying to retrieve a
LC> single selection in the list but I can't seem to get it to work.
LC> Basically the following code should allow me to get the values of the
LC> selection each time it's selected. Any help at all would be greately
LC> appreciated. Just to note I'm testing with a full clist so there isn't
LC> an issue of no data to pass.
LC> function on_clist_button_press(){
LC> $selected=$clist->selection[0];
LC> if(is_int($selected)) {
LC> echo get_text($selected, 0);
LC> }else{
LC> echo gettype($selected);
LC> }
LC> }
LC> if(mysql_numrows($result)>0){
LC> for($i=0;$i<$numrows=mysql_num_rows($result);++$i){
LC> $row[$i]=mysql_fetch_row($result);
LC> }
LC> global $clist;
LC> $clist = &new
LC> GtkCList(4,array("SSN","LName","FName","MI"));
LC> $clist->set_uposition(2,2);
LC> $clist->connect_object("button-press-event",
LC> "on_clist_button_press", $clist);
LC> foreach ($row as $app){
LC> $clist->append($app);
LC> }
LC> $clist->set_column_min_width(0, 100);
LC> $clist->set_column_min_width(1, 100);
LC> $clist->set_column_min_width(2, 100);
LC> $clist->set_column_max_width(3, 5);
LC> $clist->columns_autosize();
LC> $scroll->add($clist);
LC> $window->add($scroll);
LC> }else{
LC> $empty= &new GtkLabel("No Results Found!");
LC> $window->add($empty);
LC> }
LC> $window->show_all();
I do something like this for a single click
(setup is
->connect_after('button_press_event',array($this,'on_clist_button_press'),'Files');)
function on_clist_button_press($clist,$event,$files){
$data = '';
$row_col = $clist->get_selection_info($event->x, $event->y );
if(is_array($row_col)){
$data = $ctree->get_row_data($row_col[0]);
.
.
.
}
}
for a double click add
if ($event->type == GDK_2BUTTON_PRESS){
at the beginning
--
regards,
Tom