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();

____________________________________________________
** The Third rule of perl club is a statement of fact: pod is sexy.


In reply to How do i unbind a function bound by EVT_MENU ? by PodMaster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.