develooper Front page | perl.wxperl.users | Postings from March 2011

mouse event question

Thread Next
Bruce Ravel
March 22, 2011 15:26
mouse event question
Message ID:


I want to start by thanking Mattia for his very helpful answer to my
previous question.  

I continue to be confused by the behavior of wxperl on Windows
compared to linux.  In this case, I am surprised by the behavior of an
event bound to a right mouse click.

In this script, I have a StaticText inside of a StaticBox.  I want to
bind an action to a right click on both static items.

     package MyApp;
     use base 'Wx::App';
     use Wx qw(:everything);
     use Wx::Event qw(EVT_RIGHT_DOWN);

     sub OnInit {
       my $frame = Wx::Frame -> new(undef, -1, 'demo', [-1,-1], [250,150]);

       my $sizer    = Wx::BoxSizer->new(wxVERTICAL);
       my $box      = Wx::StaticBox->new($frame, -1, 'Blah blah');
       my $boxsizer = Wx::StaticBoxSizer->new( $box, wxVERTICAL );
       $sizer      -> Add($boxsizer, 1, wxALL, 5);
       my $st       = Wx::StaticText -> new($frame, -1, "This is some text");
       $boxsizer   -> Add($st, 1, wxGROW|wxALL, 10);

       EVT_RIGHT_DOWN($st,  sub{print "I clicked the Text!\n"});
       EVT_RIGHT_DOWN($box, sub{print "I clicked the Box!\n"});

       $frame -> SetSizerAndFit($sizer);
       $frame -> Show(1);

     package main;
     use Wx qw(:everything);
     my $app = MyApp->new->MainLoop;

On linux, the text gets printed to STDOUT when clicking on either one.
On Windows, the event for right-clicking on the StaticText happens,
but the one of right-clicking on the StaticBox does not.

Is there a reason for this?  Is there something I can do to make sure
that the event gets issued for the StaticBox?

Thanks a mmillion,


 Bruce Ravel  ------------------------------------

 National Institute of Standards and Technology
 Synchrotron Methods Group at NSLS --- Beamlines U7A, X24A, X23A2
 Building 535A
 Upton NY, 11973

 My homepage:
 EXAFS software:

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About