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...

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; }
$x and $y is taken from mouse pointer location.and we get the $row and $column from the coordination location.
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"; } } }

In reply to Problems with Gtk clist widget by coldhawk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.