From: Graciliano M. P. \(V. Sites\) <gm...@vi...> - 2002-09-04 05:34:03
|
When I try to do a ExitMainLoop from a menuitem inside a TaskBarIcon the app doesn't go out!!!! Graciliano M. P. Here a sample to test: Please send your reply and OS about the test! (Including OS and Perl version) ---------------------------------------- #!/usr/bin/perl use Wx; package MyApp; use strict; use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my( $this ) = @_; my( $frame ) = MyFrame->new( "Minimal wxPerl app", Wx::Point->new( 50, 50 ), Wx::Size->new( 450, 350 ) ); $this->SetTopWindow( $frame ); $frame->Show( 1 ); if( $Wx::_platform == $Wx::_msw ) { my $tmp = Wx::TaskBarIcon->new(); $tmp->SetIcon( Wx::GetWxPerlIcon( 1 ), "Click on me!" ); $this->{TASKBARICON} = $tmp; use Wx::Event qw(EVT_TASKBAR_LEFT_DOWN EVT_TASKBAR_RIGHT_DOWN EVT_MENU); EVT_TASKBAR_RIGHT_DOWN( $tmp, sub { my( $this, $event ) = @_; my $menu = Wx::Menu->new( "TaskBar Menu" ); $menu->Append( 100 , "ExitMainLoop" ); $menu->AppendSeparator(); $menu->Append( 101 , "Close Frame" ); $this->PopupMenu( $menu ); } ); EVT_MENU( $tmp, 100 , sub { $Wx::App::theapp->ExitMainLoop ;} ); EVT_MENU( $tmp, 101 , sub { $frame->Close ;} ); } else { print "** TaskBarIcon only on Win32!!!\n" ;} 1; } package MyFrame; use strict; use vars qw(@ISA); @ISA=qw(Wx::Frame); use Wx::Event qw(EVT_MENU); use Wx qw(wxBITMAP_TYPE_ICO wxMENU_TEAROFF); sub new { my( $class ) = shift; my( $this ) = $class->SUPER::new( undef, -1, $_[0], $_[1], $_[2] ); $this->SetIcon( Wx::GetWxPerlIcon() ); my( $mfile ) = Wx::Menu->new( undef, wxMENU_TEAROFF ); my( $ID_ABOUT, $ID_EXIT ) = ( 1, 2 ); $mfile->Append( $ID_EXIT, "E&xit\tAlt-X", "Quit this program" ); $mfile->Append( 103 , "ExitMainLoop" ); my( $mbar ) = Wx::MenuBar->new(); $mbar->Append( $mfile, "&File" ); $this->SetMenuBar( $mbar ); EVT_MENU( $this, $ID_EXIT, \&OnQuit ); EVT_MENU( $this, 103 , sub { $Wx::App::theapp->ExitMainLoop ;} ); $this->CreateStatusBar( 2 ); $this->SetStatusText( "Welcome to wxWindows!", 1 ); $this; } sub OnCreateStatusBar { my( $this ) = shift; my( $status ) = Wx::StatusBar->new( $this, -1 ); $status->SetFieldsCount( 3 ); $status; } sub OnQuit { my( $this, $event ) = @_; $this->Close( 1 ); } use Wx qw(wxOK wxICON_INFORMATION wxVERSION_STRING); package main; my( $app ) = MyApp->new(); $app->MainLoop(); #---------------------------------------- |