enroute has asked for the wisdom of the Perl Monks concerning the following question:

The following source creates a TextCtrl in a HtmlWindow. Everything looks fine except that the TextCtrl does not correspond to Copy or Cut (keyboard short cut or the right-click context menu) correctly. On the other hand, a RichTextCtrl in a HtmlWindow has no such problems. Is there any hint to solve the problem? Thanks.
#!/usr/bin/perl -w use strict; use warnings; use Wx qw/:everything/; package MyApp; use base 'Wx::App'; use Wx::Html; sub OnInit { my $frame = Wx::Frame->new( undef,-1,'TextCtrl in HtmlWindow'); my $html=Wx::HtmlWindow->new($frame,-1); $html->GetParser->AddTagHandler(MyHtmlTagHandler->new); $html->SetPage('<html><body><wxperledit /></body></html>'); $frame->Show( 1 ); } package MyHtmlTagHandler; use base 'Wx::PlHtmlTagHandler'; sub new { my $class = shift; my $this = $class->SUPER::new; return $this; } sub GetSupportedTags { return 'WXPERLEDIT'; } sub HandleTag { my( $this, $htmltag ) = @_; my $parser = $this->GetParser; my $htmlwin = $parser->GetWindow; my $entry=Wx::TextCtrl->new($htmlwin,-1,'text'); my $cell=Wx::HtmlWidgetCell->new($entry); my $cnt = $parser->GetContainer; $cnt->InsertCell( $cell ) if $cell; return 1; } package main; MyApp->new->MainLoop;

Replies are listed 'Best First'.
Re: wxperl's TextCtrl in HtmlWindow won't do Copy or Cut
by Anonymous Monk on Aug 24, 2010 at 08:20 UTC
    Its a bug in wxWidgets. If you add
    Wx::Event::EVT_CHAR( $entry, sub{warn"@_"; $_[1]->Skip; });
    you can see that the problem is upstream (Skip signals to call the upstream event handler, which is the default handler, but there is a disconnect and it doesn't get called)

    You could work around the problem by handling the event yourself, but thats just busy work.

    The real solution is to submit a bug report for both wxperl/wxwidgets.