Hi Octavian Rasnita,
I usually use MessageDialog instead of MessageBox for similar case.
So, my suggestion is as follow:
my $dialog = Wx::MessageDialog->new($self, t("Are you sure you want to
close the application?"), t("Exit"), wxYES|wxNO, wxDefaultPosition);
if($dialog->ShowModal() == wxID_YES) {
$self->Destroy();
}
On Tue, 2008-08-26 at 17:25 +0300, Octavian Rasnita wrote:
> 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
>