Ticket #15744 (closed defect: fixed)
wxRichTextCtrl: HitTest can't find top-level floats
|Reported by:||dghart||Owned by:||juliansmart|
Now that the cells of a floating wxRichTextTable are displayed, it's apparent that clicking or dragging inside one fails to set focus or select text. This can be seen in 'richtext'.
This is for two reasons. First, wxRichTextFloatCollector::HitTestFloat treats the floating control as a single object, which is correct for e.g. a wxRichTextImage, but not for a table. richtextbuffer.patch checks to see if it's top-level, and if so calls HitTest() on it.
That almost works, but unfortunately the current HitTestFloat() code does nothing to set the contextObj. That gets set later by wxRichTextParagraphLayoutBox::HitTest to be the buffer, which means that trying to select a cell's content will instead select random text outside the table, or nothing.
The fix for this is easy: just pass contextObj as an extra parameter to wxRichTextFloatCollector::HitTest and HitTestFloat. The patch does this, and it works. However I'm not sure if this extra parameter breaks binary compatibility for wx3.0. I read http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++ to mean that it should; however wxRichTextFloatCollector is defined in the cpp file and has only a forward declaration in the header, and testing here by switching richtext libs caused no problem.