Fix hit testing in generic wxDataViewToggleRenderer.
Handle clicks on the checkboxes in generic wxDataViewCtrl correctly by taking into account that the checkbox rectangle is centred inside the total cell rectangle. Closes #15144. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73835 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1090,7 +1090,7 @@ bool wxDataViewToggleRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewToggleRenderer::WXActivateCell(const wxRect& WXUNUSED(cell),
|
bool wxDataViewToggleRenderer::WXActivateCell(const wxRect& cellRect,
|
||||||
wxDataViewModel *model,
|
wxDataViewModel *model,
|
||||||
const wxDataViewItem& item,
|
const wxDataViewItem& item,
|
||||||
unsigned int col,
|
unsigned int col,
|
||||||
@@ -1098,8 +1098,16 @@ bool wxDataViewToggleRenderer::WXActivateCell(const wxRect& WXUNUSED(cell),
|
|||||||
{
|
{
|
||||||
if ( mouseEvent )
|
if ( mouseEvent )
|
||||||
{
|
{
|
||||||
// only react to clicks directly on the checkbox, not elsewhere in the same cell:
|
// Only react to clicks directly on the checkbox, not elsewhere in the
|
||||||
if ( !wxRect(GetSize()).Contains(mouseEvent->GetPosition()) )
|
// same cell.
|
||||||
|
//
|
||||||
|
// We suppose that the checkbox is centred in the total cell rectangle
|
||||||
|
// as this is how it's rendered, at least under MSW. If this turns out
|
||||||
|
// to be a wrong assumption, we probably would need to do the hit test
|
||||||
|
// checking in wxRendererNative but for now this simple solution works.
|
||||||
|
const wxRect checkRect = wxRect(GetSize()).CentreIn(cellRect);
|
||||||
|
|
||||||
|
if ( !checkRect.Contains(mouseEvent->GetPosition()) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user