Hey,
maybe I missed something but I can't find the solution (if it exist):
I have a tree with several columns. When I have the selected row I
would like to know which column was under the mouse pointer.
Is it possible to have it? How?
Thanks,
Attila
sub button_pressed_event {
my ($widget, $event) = @_;
my $treeselection = $tview->get_selection;
my ($x, $y)=$event->get_coords;
my $mouse_path=$tview->get_path_at_pos($x, $y);
if($mouse_path) {
$treeselection->select_path($mouse_path);
}
my $treeiter = $treeselection->get_selected;
if ( $treeiter ) {
if ( $event->button == 3) {
my $value1 = $model->get($treeiter,0);
my $value2 = $model->get($treeiter,4);
printf "first: " . $value1 . " second: " .
$value2 . "\n";
my $menu = Gtk2::Menu->new();
my $menuitem1 =
Gtk2::ImageMenuItem->new_from_stock('gtk-copy');
$menuitem1->signal_connect(activate => sub {
printf "selected :" . $value1 . "\n";
$clipboard->set_text($value1);
});
my $menuitem2 = Gtk2::MenuItem->new("$value2");
$menu->add($menuitem1);
$menu->add($menuitem2);
$menu->show_all;
$menu->popup(
undef, # parent menu shell
undef, # parent menu item
undef, # menu pos func
undef, # data
3,
$event->time
);
return TRUE;
}
} else {
printf "No row selected\n";
}
return FALSE;
}
Attachment:
tree_get-selected_value.pl
Description: Perl program