|
|
Choosing A Webhost: |
Re: wxPliGuard kills my events: msg#00020lang.perl.wxperl
Simon Flack wrote: I've attached a script that crashes on 0.22 but works on 0.19 and my bastardised 0.22. It requires Wx::Perl::VirtualTreeControl which is also attached. It's due for a CPAN release soon-ish (just waiting for work to sign it off). To get crashtest.pl working, remove line 9 ("use IFL::FileIO") or use the version attached to this message. --simonflk #!/usr/bin/perl # "wxPliGuard kills my events" use strict; use Cwd; use Wx ':misc'; use Wx::Perl::VirtualTreeCtrl 'EVT_POPULATE_TREE_ITEM'; sub Wx::App::OnInit {1} use File::Spec::Functions 'catfile'; # Standard stuff my $app = Wx::App->new(); my $frame = Wx::Frame->new(undef, -1, "Events Crash Test"); $app->SetTopWindow($frame); $frame->Show(1); # custom control (a lazy tree control) my $tree = Wx::Perl::VirtualTreeCtrl->new( $frame, -1, wxDefaultPosition, [300,180] ); $frame->SetClientSize($tree->GetSize); my $root = $tree->AddRoot(cwd()); $tree->SetPlData($root, cwd()); $tree->SetItemHasChildren($root, 1); # event fired when branches are expanded EVT_POPULATE_TREE_ITEM($frame, $tree, \&onPopulateTree); $tree->Expand($tree->GetRootItem); # Go $tree->SetFocus; exit $app->MainLoop(); sub onPopulateTree { my ($frame, $event) = @_; my $tree = $event->GetEventObject; my $parent = $event->GetItem; return if $parent == -1 || !$parent->IsOk; my $parent_folder = $tree->GetTree->GetPlData($parent); TRACE("Expanding item: $parent_folder"); my $child = $tree->GetFirstChild($parent); if ($child && $child != -1) { TRACE("$parent_folder already has children, could update here") } else { local *DIR; opendir DIR, $parent_folder or return; my @dirs = grep {! /^\.\.?$/ && -d catfile($parent_folder, $_)} readdir DIR; closedir DIR; TRACE("Adding " . scalar(@dirs) . " directories below $parent_folder"); foreach (@dirs) { TRACE("\tAdding $_"); my $this_folder = catfile($parent_folder, $_); $child = $tree->AppendItem($parent, $_, 0, 0); $tree->SetPlData($child, $this_folder); $tree->SetItemImage($child, 0); $tree->SetItemHasChildren($child, 1); # let item be expanded } } $event->Skip; } sub TRACE { 1 && print "@_\n" }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | wxPliGuard kills my events, Simon Flack |
|---|---|
| Next by Date: | Re: Message boxes, Cheetah |
| Previous by Thread: | wxPliGuard kills my events, Simon Flack |
| Next by Thread: | Re[2]: wxPliGuard kills my events, Mattia Barbon |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |