How does the following work out?
sub OnExit {
my ($self, $event) = @_;
my $result = Wx::MessageBox(t("Are you sure you want to close the
application?"), t("Exit"), wxYES|wxNO);
if ($result == wxYES) {
$event->Skip(1);
$self->Destroy;
} else {
$event->Skip(0);
}
}
Octavian Rasnita wrote:
> Thank you Daniel,
>
> I think something's wrong with my WxPerl because that error doesn't
> appear always.
>
> If I run the program for more times, it works, then for some more times
> it gives that error.
>
> The code is very simple so I am sure I wasn't doing something wrong.
>
> BTW, the t() function is used by Wx::Locale for translating the string
> that's passed as a parameter.
>
> Thank you.
>
> Octavian
>
> From: "Daniel" <[EMAIL PROTECTED]>
> Hi,
>
> I tried your sub with EVT_CLOSE Event (without the t-sub, don't know
> what this is for) and it works fine.
>
> EVT_CLOSE( $self, sub {
> my ($self, $event) = @_;
>
> my $result = Wx::MessageBox("Are you sure you want to close the
> application?", "Exit", wxYES|wxNO);
>
> if ($result == wxYES) {
> $self->Destroy;
> }
> });
>
>
> Greez
> Daniel
>
>
>
>
>
> ----- Ursprüngliche Mail ----
> Von: Octavian Rasnita <[EMAIL PROTECTED]>
> An: [email protected]
> Gesendet: Dienstag, den 26. August 2008, 16:25:41 Uhr
> Betreff: strange error
>
> Hi,
>
> I made an app with a menu that has an "Exit" item which if clicked, it is
> handled by the following event handler:
>
> sub OnExit {
> my ($self, $event) = @_;
>
> my $result = Wx::MessageBox(t("Are you sure you want to close the
> application?"), t("Exit"), wxYES|wxNO);
>
> if ($result == wxYES) {
> $self->Destroy;
> }
> }
>
> If I click the "no" button, all works fine, but if I choose yes to close
> the
> application, it appears a perl interpreter error window.
>
> It is strange, because if I don't open that MessageBox, it doesn't appear
> that error, although the same code is executed.
> I've seen that even if I open a simple message box in the event handler
> subroutine and I just print a message without checking for a return
> code, it
> still gives that error.
>
> The following handler works fine:
>
> sub OnExit {
> my ($self, $event) = @_;
> $self->Destroy;
> }
>
> Does it happen for you also or I need to re-install perl or WxPerl?
>
> Thank you.
>
> Octavian
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com