Close the cell editor when the editors combobox is closed
Closes #16404
This commit is contained in:
committed by
Ian McInerney
parent
099ea7176d
commit
8b7fdc5e5b
@@ -335,6 +335,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
wxComboBox *Combo() const { return (wxComboBox *)m_control; }
|
wxComboBox *Combo() const { return (wxComboBox *)m_control; }
|
||||||
|
|
||||||
|
void onComboCloseUp(wxCommandEvent& evt);
|
||||||
|
void onComboDropDown(wxCommandEvent& evt);
|
||||||
|
|
||||||
wxString m_value;
|
wxString m_value;
|
||||||
wxArrayString m_choices;
|
wxArrayString m_choices;
|
||||||
bool m_allowOthers;
|
bool m_allowOthers;
|
||||||
|
@@ -1580,7 +1580,12 @@ void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid)
|
|||||||
|
|
||||||
wxGridCellEditorEvtHandler* evtHandler = NULL;
|
wxGridCellEditorEvtHandler* evtHandler = NULL;
|
||||||
if (m_control)
|
if (m_control)
|
||||||
|
{
|
||||||
|
// These event handlers are needed to properly dismiss the editor when the popup is closed
|
||||||
|
m_control->Bind(wxEVT_COMBOBOX_DROPDOWN, &wxGridCellChoiceEditor::onComboDropDown, this);
|
||||||
|
m_control->Bind(wxEVT_COMBOBOX_CLOSEUP, &wxGridCellChoiceEditor::onComboCloseUp, this);
|
||||||
evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler);
|
evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler);
|
||||||
|
}
|
||||||
|
|
||||||
// Don't immediately end if we get a kill focus event within BeginEdit
|
// Don't immediately end if we get a kill focus event within BeginEdit
|
||||||
if (evtHandler)
|
if (evtHandler)
|
||||||
@@ -1679,6 +1684,35 @@ wxString wxGridCellChoiceEditor::GetValue() const
|
|||||||
return Combo()->GetValue();
|
return Combo()->GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGridCellChoiceEditor::onComboDropDown(wxCommandEvent& WXUNUSED(evt))
|
||||||
|
{
|
||||||
|
wxGridCellEditorEvtHandler* evtHandler = wxDynamicCast(m_control->GetEventHandler(),
|
||||||
|
wxGridCellEditorEvtHandler);
|
||||||
|
|
||||||
|
if ( !evtHandler )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Once the combobox is dropped, reset the flag to allow the focus-loss handler
|
||||||
|
// to function and close the editor.
|
||||||
|
evtHandler->SetInSetFocus(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGridCellChoiceEditor::onComboCloseUp(wxCommandEvent& WXUNUSED(evt))
|
||||||
|
{
|
||||||
|
wxGridCellEditorEvtHandler* evtHandler = wxDynamicCast(m_control->GetEventHandler(),
|
||||||
|
wxGridCellEditorEvtHandler);
|
||||||
|
|
||||||
|
if ( !evtHandler )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Forward the combobox close up event to the cell event handler as a focus kill event
|
||||||
|
// so that the grid editor is dismissed when the combox closes, otherwise it leaves the
|
||||||
|
// dropdown arrow visible in the cell.
|
||||||
|
wxFocusEvent event(wxEVT_KILL_FOCUS, m_control->GetId());
|
||||||
|
event.SetEventObject(m_control);
|
||||||
|
evtHandler->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_COMBOBOX
|
#endif // wxUSE_COMBOBOX
|
||||||
|
|
||||||
#if wxUSE_COMBOBOX
|
#if wxUSE_COMBOBOX
|
||||||
|
Reference in New Issue
Block a user