develooper Front page | perl.wxperl.users | Postings from January 2013

Getting information from EVT_LIST_ITEM_RIGHT_CLICK

Thread Next
From:
Dave Hayes
Date:
January 31, 2013 22:41
Subject:
Getting information from EVT_LIST_ITEM_RIGHT_CLICK
Message ID:
510AF300.3060604@jetcafe.org
Hello. I'm trying to get the text, column, and item index on a right 
click in a Wx::ListCtrl. The item index works perfectly. However, I 
can't seem to get any other information. Here's a very abbreviated idea 
of what I am doing:

   package MyList;
   use base qw(Wx::ListCtrl);

   ...
   sub new {
     my $self = shift;
     my $params = shift;

     $self = $self->SUPER::new(
       $params->{'parent'},
       -1,
       wxDefaultPosition,
       [ 600, 400 ],
       wxLC_REPORT|wxLC_VIRTUAL|wxLC_HRULES,
     );

   ...
     EVT_LIST_ITEM_RIGHT_CLICK(
       $self, $self,
       sub {
         my ($self, $event) = @_;
         my $item = $event->GetItem();
         my $index = $event->GetIndex();
         my $text = $event->GetText();
         my $col = $item->GetColumn();
         my $data = $item->GetData();
         my $text2 = $item->GetText();

         print "Item index $index => '$text' ($col, $data, $text2)\n";
     });

   return $self;
   }

This prints, for example:

   Item index 19 => '' (0, 0, )

What am I doing wrong, if anything? Thanks in advance.
-- 
Dave Hayes - Consultant - Altadena CA, USA - dave@jetcafe.org
 >>>> *The opinions expressed above are entirely my own* <<<<

Sometimes what a person escapes to is worse than what they
escaped from.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About