X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f5851311d3cafff78097f8441d3dc5bf1fc1e6b0..795b0f144495454aac0dc23e865f7a8f87f6dfa3:/src/msw/checklst.cpp diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 933537bc1b..98a4e6763b 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -483,9 +483,19 @@ void wxCheckListBox::OnLeftClick(wxMouseEvent& event) if ( nItem != wxNOT_FOUND ) { - wxCheckListBoxItem *item = GetItem(nItem); - item->Toggle(); - item->SendEvent(); + // 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 }