From: DH <cra...@ya...> - 2002-08-10 21:29:42
|
I've asked this first at http://perlmonks.com/index.pl?node_id=189173 this morning (early early early early) After seeing that Vacation notice, I decided to post here as well (i was gonna wait a day or two to see if anybody responds) Anyway, here goes, HEEEEEEEELP! ;) In wxPerl, if i use EVT_MENU($this, 123, sub{warn 1} ); to essentially "bind" that anon-sub to the 123 id, how do I go about unbinding it (is that even the right terminology)? I've tried EVT_MENU($this, 123, sub{warn 2} ); EVT_MENU($this, 123, undef ); which doesn't work. Is it even possible? (i suspect it's not, but I can't be sure) If i don't get any replies, I will ask on the wxPerl mailing list. Heere's test code #!/usr/bin/perl use Wx; # every program must have a Wx::App-derive class package MyApp; use strict; use vars qw(@ISA); @ISA=qw(Wx::App); use Wx qw[ :everything ]; use Wx::Event qw[ EVT_MENU ]; # this is called automatically on object creation sub OnInit { my( $this ) = @_; # create new MyFrame my( $frame ) = MyFrame->new( "Accelerator Test", Wx::Point->new( 50, 50 ), Wx::Size->new( 450, 350 ) ); my $menuBar = new Wx::MenuBar(); my $menu = new Wx::Menu(); $menu->Append( 123, "&About...\tCtrl-A", "Show about dialog." ); EVT_MENU($frame, 123, sub { warn "PUCK"; print Dumper\@_; EVT_MENU($frame, 123, undef); EVT_MENU($frame, 123, sub{ die "DIFFERENT" }); } ); $menuBar->Append($menu, "Info"); $frame->SetMenuBar( $menuBar ); EVT_MENU($frame, 321, sub { warn "I'm FAKING IT, I'm FAKING IT GOOD @_" } ); my $ACCL = new Wx::AcceleratorTable( [ wxACCEL_CTRL, 'C', ### NEEDS TO BE CAPITAL ( UNDOCUMENTED ) 123, ], [ wxACCEL_CTRL, 'Q', 321, ], ); $frame->SetAcceleratorTable($ACCL); # set it as top window (so the app will automatically close when # the last top window is closed) $this->SetTopWindow( $frame ); # show the frame $frame->Show( 1 ); 1; } package MyFrame; use strict; use vars qw(@ISA); @ISA=qw(Wx::Frame); use Wx qw(wxBITMAP_TYPE_BMP wxMENU_TEAROFF); # Parameters: title, position, size sub new { my( $class ) = shift; my( $this ) = $class->SUPER::new( undef, -1, $_[0], $_[1], $_[2] ); $this; } package main; # create an instance of the Wx::App-derived class my( $app ) = MyApp->new(); # start processing events $app->MainLoop(); __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com |