From: Everett, T. <TEv...@AL...> - 2002-09-04 21:38:31
|
Just in case there are questions, I'm running wxPerl 0.11, wxWindows 2.2.9, from the PPM package on the website, under ActivePerl build 623. The following code (as small as I could get it - what is the completely minimal Wx "Hello World" program?) reproduces the problems - both can be demonstrated by swapping in a 0 for the 1 in the respective trinary conditionals. In the case of passing -1 to Wx::MenuItem::new, the menuitem simply never shows up in the menu. In the case of passing $mexit instead of $mexit->GetId to EVT_MENU, the event binding isn't implemented. ===== BEGIN CODE===== use strict; package MyFrame; use Wx; use Wx::Event qw(EVT_MENU); use vars qw(@ISA); @ISA=qw(Wx::Frame); sub new { my $class = shift; my $self = $class->SUPER::new(undef, -1, $_[0], $_[1], $_[2]); my $mbar = Wx::MenuBar->new(); $self->SetMenuBar($mbar); my $mfile = Wx::Menu->new(); $mbar->Append($mfile, "&File"); my $mexit = Wx::MenuItem->new($mfile, (1 ? 101 : -1), "E&xit\tAlt-X", "Quit this program"); $mfile->Append($mexit); EVT_MENU($self, (1 ? $mexit->GetId : $mexit), sub {$self->Close(1)}); return $self; } package MyApp; use Wx qw(wxDefaultPosition); use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my $self = shift; my $frame = MyFrame->new("Minimal wxPerl app", wxDefaultPosition, [450, 350]); $self->SetTopWindow($frame); $frame->Show(1); } package main; (my $app = MyApp->new())->MainLoop(); ======END CODE====== --Toby Everett -----Original Message----- From: Mattia Barbon [mailto:mb...@ds...] Sent: Wednesday, September 04, 2002 8:32 AM To: Everett, Toby Cc: wxp...@li... Subject: Re: [wxperl-users] Minor inconsistency using MenuItem and EVT_MENU > I was playing around with using -1 as the passed control ID in the > constructor as described in > http://wxperl.sourceforge.net/manual/manual4.html > <http://wxperl.sourceforge.net/manual/manual4.html> . I noticed that it > doesn't work:). In the interim, I've simply created an interator in my "It does nt work" as in "it works as documented but does not do what I want" or as in "it does not work as documented"? If it is the latter, it might be useful to show some (small) sample code that in your opinion is misbehaving. > package and used that for the constructor. I also noticed that I had to > explicitly call ->GetId() when using EVT_MENU. For this one too. Regards Mattia |