Passing arguments to event handlers in WxPerl is something you never have to do :)

Having code outside of subroutines is something you never have to do :) (really shouldn't )

EVT_COMBOBOX ... How is this done?

As documented :) my wxWidgets / wxPerl / wxGlade tutorial, wxperl_usage / wxperl-usage / wxPerl::Usage / Class Method Browser , available methods, method invocation syntax, link to docs

sub Combobox1action { my( $frame, $comboevent ) = @_; my $combobox = $comboevent->GetEventObject; my $selection = $comboevent->GetString; $frame->SetTitle( "Combo box selected ($selection)" ); }


http://docs.wxwidgets.org/2.8.12/wx_wxcommandevent.html#wxcommandeventgetstring
http://docs.wxwidgets.org/2.8.12/wx_wxevent.html#wxeventgeteventobject

Re^2: How do i color font in a listbox? ( wx-listctrl-coloritems-findselect.pl )

wx-combobox-event.pl

#!/usr/bin/perl -- ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END " -otr -opr -ce +-nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while " -otr + -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Wx 0.86 qw( ); Main( @ARGV ); exit( 0 ); sub Main { my $app = Wx::SimpleApp->new; my $f = Wx::Frame->new( undef, -1, "", ); my $cb = Wx::ComboBox->new( $f, -1, "", [-1,-1,], [-1,-1,], [ 22 .. 33 ], ); $cb->SetFocus; $f->SetSizer( Wx::BoxSizer->new( Wx::wxVERTICAL() ) ); $f->GetSizer->Add( $cb, 0, Wx::wxEXPAND() ); $f->GetSizer->SetSizeHints( $f ); $f->Show( 1 ); $app->SetTopWindow( $f ); #~ Wx::Event::EVT_COMBOBOX( $app, $cb, \&Combobox1action ); Wx::Event::EVT_COMBOBOX( $f, $cb, \&Combobox1action ); $app->{cb} = $cb; $app->MainLoop; } ## end sub Main sub Combobox1action { my( $frame, $comboevent ) = @_; my $combobox = $comboevent->GetEventObject; my $selection = $comboevent->GetString; #~ my $selection = $combobox->GetValue; $frame->SetTitle( "Combo box selected ($selection)" ); } ## end sub Combobox1action __END__

In reply to Re: Passing arguments to event handlers in WxPerl (is something you never have to do; wx-combobox-event.pl) by Anonymous Monk
in thread Passing arguments to event handlers in WxPerl by pwn01

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.