-int wxCheckListBox::DoHitTestItem(wxCoord x, wxCoord y) const
-{
- int nItem = (int)::SendMessage
- (
- (HWND)GetHWND(),
- LB_ITEMFROMPOINT,
- 0,
- MAKELPARAM(x, y)
- );
-
- return nItem >= (int)m_noItems ? wxNOT_FOUND : nItem;
+ if ( nItem != wxNOT_FOUND )
+ {
+ // people expect to get "kill focus" event for the currently
+ // focused control before getting events from the other controls
+ // and, equally importantly, they may prevent the focus change from
+ // taking place at all (e.g. because the old control contents is
+ // invalid and needs to be corrected) in which case we shouldn't
+ // generate this event at all
+ SetFocus();
+ if ( FindFocus() == this )
+ {
+ wxCheckListBoxItem *item = GetItem(nItem);
+ item->Toggle();
+ item->SendEvent();
+ }
+ }
+ //else: it's not an error, just click outside of client zone
+ }
+ else
+ {
+ // implement default behaviour: clicking on the item selects it
+ event.Skip();
+ }