coldhawk has asked for the wisdom of the Perl Monks concerning the following question:
im using Gtk Perl module and im trying to get the text from clist widget using coordinations but im having this problem it doesn't work at all, it returns strange values and the last clist entrys it gives nothing. I have read many documents i could find anything usefull and i checked some programs and still i could't find any working solution. i hope you could direct me somewhere. The final idea is just to remove selected row when clicking right button using popup menu, Delete item.
if i use the: $clist->signal_connect("select_row", \&menu); then the $event->{button} only returns the 1, not any other buttons.
i have this signal in my Window widget $main_window->signal_connect(button_press_event => \&menu);
this displays the menu and when menu item is clicked it goes the do_remove sub. even this could be done in one sub...
$x and $y is taken from mouse pointer location.and we get the $row and $column from the coordination location.sub menu { my (undef, $event) = @_; if ($event->{type} =~ /button[-_]press/ and ($event->{button} == 2 or +$event->{button} == 3)) { my $menu_menu = new Gtk::Menu; my $menu_item = new Gtk::MenuItem('Delete it.'); $menu_item->show; $menu_menu->append($menu_item); $menu_menu->show; $menu_item->signal_connect("activate" => \&do_remove); $menu_menu->popup(undef, undef, $event, $event->{'time'}); } return 1; }
sub do_remove { my ($x, $y) = $main_clist->get_pointer; my ($row, $column) = $main_clist->get_selection_info($x, $y); $column = 0; if (defined $row && defined $column) { my $text = $main_clist->get_text($row, $column) || undef; if (defined $text) { print $text . "\n"; } } }
|
---|