From af8fc1161cc10818b95bea8f08c2bd0995a1964d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 2 Nov 2007 00:27:13 +0000 Subject: [PATCH] try (this can be vetoed) to set focus to the listbox before generating the events (patch 1822109) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49593 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/checklst.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 } -- 2.45.2