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:

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?


In reply to Win32::GUI::Richedit strange results for deselecting a selection by tomsell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.