Show the exact wxTextCtrlHitTestResult in the text sample too

In addition to showing the position returned by HitTest(), also show its
return value which is not necessarily wxTE_HT_ON_TEXT if it is not
wxTE_HT_UNKNOWN under MSW.
This commit is contained in:
Vadim Zeitlin 2017-08-25 01:03:36 +02:00
parent dd63efe986
commit de9b6fdc9e

View File

@ -811,11 +811,32 @@ void MyTextCtrl::OnMouseEvent(wxMouseEvent& ev)
long pos;
wxTextCtrlHitTestResult rc = HitTest(ev.GetPosition(), &pos);
if ( rc != wxTE_HT_UNKNOWN )
wxString where;
switch ( rc )
{
msg << wxT("at position ") << pos << wxT(' ');
case wxTE_HT_UNKNOWN:
break;
case wxTE_HT_BEFORE:
where = "before";
break;
case wxTE_HT_ON_TEXT:
where = "at";
break;
case wxTE_HT_BELOW:
where = "below";
break;
case wxTE_HT_BEYOND:
where = "beyond";
break;
}
if ( !where.empty() )
msg << where << " position " << pos << " ";
msg << wxT("[Flags: ")
<< GetChar( ev.LeftIsDown(), wxT('1') )
<< GetChar( ev.MiddleIsDown(), wxT('2') )