WxWidget/WxPerl, more instances of WxApp, EVENT handling
<p>I'm trying make a script, which create <strong>more then one simple window</strong> (it inherit from WxApp). Window contains only one button and handler for click EVENT.</p>

<p>Problem is handling click event, when more then one window is exist. If exists only one instance of window, event is detected correctly. It seems, event works out correctly always in last created window. I can't figure out, where could be problem... In this sample, after clicking on button in first created window, it seems, thet <strong>event is catched in second window</strong>. It prints "2" to console, instead of "1".</p>

<pre><code>package MyApp;
use base 'Wx::App';

use strict;
use warnings;
use Wx;
use aliased 'Widgets::Forms::MyWxFrame';

sub new {

    my $self = shift;
    $self = {};
    $self = Wx::App-&gt;new( \&amp;OnInit );
    bless($self);

    $self-&gt;{"windowNumber"} = shift;

    my $mainFrm = MyWxFrame-&gt;new(
        undef,                     
        -1,                        
        "My app - ".$self-&gt;{"windowNumber"},
        &amp;Wx::wxDefaultPosition
    );

    my $button = Wx::Button-&gt;new( $mainFrm, -1, "Test btn", );
    Wx::Event::EVT_BUTTON( $button, -1, sub { __OnClick( $self, @_ ) } );

    $mainFrm-&gt;Show(1);
    return $self;
}

sub OnInit {
    return 1;
}

sub __OnClick {
    my $self  = shift;
    my $btn   = shift;
    my $event = shift;

    print $self-&gt;{"windowNumber"};
}

my $myApp = MyApp-&gt;new(1);
my $myApp2 = MyApp-&gt;new(2);


$myApp-&gt;MainLoop;
</code></pre>