From 3ac2562a7ffec349ffc1f1d0236dfce3fc47b87c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 2 Jul 2012 10:28:03 +0000 Subject: [PATCH] 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 --- docs/changes.txt | 1 + src/generic/grideditors.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) 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), -- 2.45.2