wxListBox in wxUniv need to overwrite DoListHistTest function, otherwise Listbox::HitTest will call DoListHitTest in wx/listbox.h, which will always return wxNOT_FOUND

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77792 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-09-23 17:40:36 +00:00
parent 831045ff45
commit 26ce3d6361
2 changed files with 30 additions and 0 deletions

View File

@ -116,6 +116,8 @@ protected:
void **clientData,
wxClientDataType type) wxOVERRIDE;
virtual int DoListHitTest(const wxPoint& point) const wxOVERRIDE;
// universal wxComboBox implementation internally uses wxListBox
friend class WXDLLIMPEXP_FWD_CORE wxComboBox;

View File

@ -1112,6 +1112,34 @@ void wxListBox::Activate(int item)
}
}
// ----------------------------------------------------------------------------
// hittest
// ----------------------------------------------------------------------------
int wxListBox::DoListHitTest(const wxPoint& point) const
{
if ( !GetClientRect().Contains(point) )
return wxNOT_FOUND;
int y, index;
CalcUnscrolledPosition(0, point.y, NULL, &y);
index = y / GetLineHeight();
if ( index < 0 )
{
// mouse is above the first item
index = 0;
}
else if ( (unsigned int)index >= GetCount() )
{
// mouse is below the last item
index= GetCount() - 1;
}
return index;
}
// ----------------------------------------------------------------------------
// input handling
// ----------------------------------------------------------------------------