From 3603a3895ed72d1b70537cfa0c435a113b8c4af6 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 30 Mar 2006 15:25:59 +0000 Subject: [PATCH] Fix wxListCtrl in-place editing (to not crash when editin is finished by clicking somewhere else and thus taking the focus away from the wxTextCtrl). Also, "delete this" in the middle of code isn't optimal. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38450 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/listctrl.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 043001015c..6ba376db61 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2033,6 +2033,8 @@ wxListTextCtrlWrapper::wxListTextCtrlWrapper(wxListMainWindow *owner, m_text->Create(owner, wxID_ANY, m_startValue, wxPoint(rectLabel.x-4,rectLabel.y-4), wxSize(rectLabel.width+11,rectLabel.height+8)); + m_text->SetFocus(); + m_text->PushEventHandler(this); } @@ -2045,7 +2047,7 @@ void wxListTextCtrlWrapper::Finish() m_text->RemoveEventHandler(this); m_owner->FinishEditing(m_text); - delete this; + wxPendingDelete.Append( this ); } } @@ -2087,8 +2089,8 @@ void wxListTextCtrlWrapper::OnChar( wxKeyEvent &event ) break; case WXK_ESCAPE: - Finish(); m_owner->OnRenameCancelled( m_itemEdited ); + Finish(); break; default: @@ -2123,16 +2125,13 @@ void wxListTextCtrlWrapper::OnKillFocus( wxFocusEvent &event ) { if ( !m_finished && !m_aboutToFinish ) { - // We must finish regardless of success, otherwise we'll get - // focus problems: - Finish(); - if ( !AcceptChanges() ) m_owner->OnRenameCancelled( m_itemEdited ); + + Finish(); } - // We must let the native text control handle focus, too, otherwise - // it could have problems with the cursor (e.g., in wxGTK). + // We must let the native text control handle focus event.Skip(); } -- 2.47.2