tomsell has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I wonder if people could confirm an observation I made when interacting with a Win32::GUI::Richedit control.
To deselect selected text, one can click outside of the selection or within the selection. Strangely though, a handler for the MouseUp event will see different values when querying the Richedit control upon clicking the control:
outside of the selected text: selection start and end are the same, ie. an insertion point, which is OK.
within the selection: although the text ist deselected, querying the control still returns the values of the old selection, which is NOT OK!
Note that the Textfield control behaves correctly.
Here's the runnable code for Richedit and Textfield which prints to STDERR
use Win32::GUI(); my $mw = Win32::GUI::Window->new(-title => "Richedit / Textfield desel +ecting differences", -size => [500,200]); my $re = $mw->AddRichEdit(-name => "re", -pos => [0,0], -size => [500 +, 100], -text => "RichEdit\r\ndouble click to select, then single cli +ck _outside of_ selection: \$start == \$end,\r\ndouble click to selec +t, then single-click _within_ selection: \$start != \$end"); my $tf = $mw->AddTextfield(-name => "tf", -pos => [0,101], -size => [ +500, 99], -text => "Textfield\r\ndouble click to select, then single +click _outside of_ selection: \$start == \$end,\r\ndouble click to se +lect, then single-click _within_ selection: \$start == \$end", -multi +line => 1); $mw->Show(); Win32::GUI::Dialog(); exit(0); sub re_MouseUp { my ($start, $end) = $re->GetSel(); print STDERR "RichEdit MouseUp selection: $start, $end\n"; 1; } sub tf_MouseUp { my ($start, $end) = $tf->GetSel(); print STDERR "TextField MouseUp selection: $start, $end\n"; 1; }
Background to this: I'd like to to enable/disable a "Copy Selected Text" toolbar button based on the presence of selected text. Is this the right approach or might there be a workaround for the RichEdit behaviour?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Win32::GUI::Richedit strange results for deselecting a selection (events)
by Anonymous Monk on Feb 07, 2013 at 08:56 UTC | |
by tomsell (Acolyte) on Apr 08, 2013 at 20:14 UTC | |
Re: Win32::GUI::Richedit strange results for deselecting a selection
by Athanasius (Archbishop) on Feb 07, 2013 at 14:37 UTC | |
by Anonymous Monk on Feb 07, 2013 at 15:15 UTC |