you putted the EVT_CLOSE to the wrong place...
or do you have a reason why you need it to be there?
$app ist not the window, but you could use EVT_CLOSE on $frame too.
i changed your minimal sample that it works.
hope it helps
greeting
Marco
----
use Wx;
###########################
package MyApp;
use strict;
use vars qw(@ISA);
@ISA=qw(Wx::App);
sub OnInit
{
my( $this ) = @_;
my( $frame ) = MyFrame->new( "Minimal wxPerl app",
Wx::Point->new( 50, 50 ),
Wx::Size->new( 450, 350 )
);
$this->SetTopWindow( $frame );
$frame->Show( 1 );
1;
}
###########################
package MyFrame;
use strict;
use vars qw(@ISA);
@ISA=qw(Wx::Frame);
use Wx::Event qw(EVT_CLOSE);
sub new
{
my( $class ) = shift;
my( $this ) = $class->SUPER::new( undef, -1, $_[0], $_[1], $_[2] );
EVT_CLOSE( $this , \&onClose);
$this;
}
sub onClose
{
my ($this, $event) = @_;
print "try to close...\n";
$event->Skip; # allow to close
}
###########################
package main;
my ($app) = MyApp->new();
$app->MainLoop();
|