X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ff0d9d83cd088b9f7c925db8262f86674a320724..35bb3cb155917b4287fb2a3841bea22919a3d499:/src/msw/checklst.cpp diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 3188137aca..98a4e6763b 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -29,7 +29,7 @@ #include "wx/checklst.h" #ifndef WX_PRECOMP - #include "wx/msw/wrapwin.h" + #include "wx/msw/wrapcctl.h" #include "wx/object.h" #include "wx/colour.h" #include "wx/font.h" @@ -124,7 +124,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox) class wxCheckListBoxItem : public wxOwnerDrawn { -friend class WXDLLEXPORT wxCheckListBox; +friend class WXDLLIMPEXP_FWD_CORE wxCheckListBox; public: // ctor wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex); @@ -251,6 +251,7 @@ void wxCheckListBoxItem::SendEvent() wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, m_pParent->GetId()); event.SetInt(m_nIndex); event.SetEventObject(m_pParent); + event.SetString(m_pParent->GetString(m_nIndex)); m_pParent->ProcessCommand(event); } @@ -482,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 }