diff --git a/docs/changes.txt b/docs/changes.txt index 4c3af62f96..b9ddbc9b5b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -577,6 +577,7 @@ GTK: - Implement native tab art for wxAUI (Jens Lody and Teodor Petrov). - Fix pasting large amounts of text (Bradley Hawkins). - Show gstreamer errors if wxMediaCtrl fails to play file. +- Fix wxGridCellEnumEditor mouse handling (Fulvio Senore). MSW: diff --git a/src/generic/grideditors.cpp b/src/generic/grideditors.cpp index de8831342a..fabd2b9227 100644 --- a/src/generic/grideditors.cpp +++ b/src/generic/grideditors.cpp @@ -1596,6 +1596,14 @@ void wxGridCellEnumEditor::BeginEdit(int row, int col, wxGrid* grid) wxASSERT_MSG(m_control, wxT("The wxGridCellEnumEditor must be Created first!")); + wxGridCellEditorEvtHandler* evtHandler = NULL; + if (m_control) + evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler); + + // Don't immediately end if we get a kill focus event within BeginEdit + if (evtHandler) + evtHandler->SetInSetFocus(true); + wxGridTableBase *table = grid->GetTable(); if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) ) @@ -1618,6 +1626,22 @@ void wxGridCellEnumEditor::BeginEdit(int row, int col, wxGrid* grid) Combo()->SetSelection(m_index); Combo()->SetFocus(); +#ifdef __WXOSX_COCOA__ + // This is a work around for the combobox being simply dismissed when a + // choice is made in it under OS X. The bug is almost certainly due to a + // problem in focus events generation logic but it's not obvious to fix and + // for now this at least allows to use wxGrid. + Combo()->Popup(); +#endif + + if (evtHandler) + { + // When dropping down the menu, a kill focus event + // happens after this point, so we can't reset the flag yet. +#if !defined(__WXGTK20__) + evtHandler->SetInSetFocus(false); +#endif + } } bool wxGridCellEnumEditor::EndEdit(int WXUNUSED(row),