Allow using wxGridCellEnumEditor with the mouse.

Previously the combobox was immediately dismissed when the mouse was used.

Fix this by copying the code from wxGridCellChoiceEditor to this class. This
is obviously not ideal and both classes should be refactored to avoid this in
the future but for now this at least fixes the user-visible problem.

Closes #13943.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71933 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2012-07-02 10:28:03 +00:00
parent 5208671fbb
commit 3ac2562a7f
2 changed files with 25 additions and 0 deletions

View File

@ -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:

View File

@ -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),