From: Peter T. <peter@PeterTheobald.com> - 2006-08-14 19:09:25
|
<html> <body> <font size=3>(sorry about the bad subject on the previous post attempt...)<br><br> I need to find which word in a multi-line TextCtrl has been right-clicked on.<br> I cannot find any way of doing this.<br><br> I hacked together something nasty to find which word is left-click using the insertion point:<br> <x-tab> </x-tab>my $ip=$self->GetInsertionPoint();<br> <x-tab> </x-tab>my ($px,$py)=$self->PositionToXY($ip);<br> <x-tab> </x-tab>my $clickedline=$self->GetLineText($py);<br> <x-tab> </x-tab>my ($prefix) = substr($clickedline,0,$px) =~ /([\w'`]+)$/;<br> <x-tab> </x-tab>my ($suffix)= substr($clickedline,$px,1000) =~ /^([\w+'`]+)/;<br> <x-tab> </x-tab>my $clickedword=$prefix.$suffix;<br><br> But right-clicking doesn't set the insertion point. I cannot simply use the Y coordinate because I don't know the line-height of the text in the TextCtrl.<br><br> HELP!<br><br> Thanks in advance,<br> -Peter<br> </font></body> </html> |