From 140954fd9cb214e81469aea705f0dda801369e49 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 2 Jun 2005 11:38:16 +0000 Subject: [PATCH] hide the cell editor if the grid loses focus git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34524 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/grid.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 395e94ac5d..26b0750fc4 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -240,27 +240,30 @@ private: class wxGridCellEditorEvtHandler : public wxEvtHandler { public: - wxGridCellEditorEvtHandler() - : m_grid(0), m_editor(0) - { } wxGridCellEditorEvtHandler(wxGrid* grid, wxGridCellEditor* editor) - : m_grid(grid), m_editor(editor) - { } + : m_grid(grid), + m_editor(editor) + { + } + void OnKillFocus(wxFocusEvent& event); void OnKeyDown(wxKeyEvent& event); void OnChar(wxKeyEvent& event); private: wxGrid* m_grid; wxGridCellEditor* m_editor; - DECLARE_DYNAMIC_CLASS(wxGridCellEditorEvtHandler) + DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS(wxGridCellEditorEvtHandler) DECLARE_NO_COPY_CLASS(wxGridCellEditorEvtHandler) }; -IMPLEMENT_DYNAMIC_CLASS( wxGridCellEditorEvtHandler, wxEvtHandler ) +IMPLEMENT_ABSTRACT_CLASS(wxGridCellEditorEvtHandler, wxEvtHandler) + BEGIN_EVENT_TABLE( wxGridCellEditorEvtHandler, wxEvtHandler ) + EVT_KILL_FOCUS( wxGridCellEditorEvtHandler::OnKillFocus ) EVT_KEY_DOWN( wxGridCellEditorEvtHandler::OnKeyDown ) EVT_CHAR( wxGridCellEditorEvtHandler::OnChar ) END_EVENT_TABLE() @@ -1520,6 +1523,14 @@ wxString wxGridCellChoiceEditor::GetValue() const // wxGridCellEditorEvtHandler // ---------------------------------------------------------------------------- +void wxGridCellEditorEvtHandler::OnKillFocus(wxFocusEvent& event) +{ + // accept changes + m_grid->DisableCellEditControl(); + + event.Skip(); +} + void wxGridCellEditorEvtHandler::OnKeyDown(wxKeyEvent& event) { switch ( event.GetKeyCode() ) -- 2.45.2