X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e179bd6537b8e3d7543d23db3b6735ea7effe159..60b6c062f847a742fbc3c4ba4023bb8a0235da6d:/src/generic/listctrl.cpp?ds=sidebyside diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index f9b74282d5..65f568eb3b 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -20,7 +20,7 @@ #include "wx/dcscreen.h" #include "wx/app.h" -#include "wx/generic/listctrl.h" +#include "wx/listctrl.h" #include "wx/generic/imaglist.h" //----------------------------------------------------------------------------- @@ -899,6 +899,9 @@ wxListTextCtrl::wxListTextCtrl( wxWindow *parent, const wxWindowID id, m_res = res; m_accept = accept; m_owner = owner; + (*m_accept) = FALSE; + (*m_res) = ""; + m_startValue = value; } void wxListTextCtrl::OnChar( wxKeyEvent &event ) @@ -907,15 +910,14 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event ) { (*m_accept) = TRUE; (*m_res) = GetValue(); - m_owner->OnRenameAccept(); - if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); + m_owner->SetFocus(); return; } if (event.m_keyCode == WXK_ESCAPE) { (*m_accept) = FALSE; (*m_res) = ""; - if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); + m_owner->SetFocus(); return; } event.Skip(); @@ -923,10 +925,12 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event ) void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) ) { - (*m_accept) = FALSE; - (*m_res) = ""; - if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); - return; + if (wxPendingDelete.Member(this)) return; + + wxPendingDelete.Append(this); + + if ((*m_accept) && ((*m_res) != m_startValue)) + m_owner->OnRenameAccept(); } //----------------------------------------------------------------------------- @@ -1139,10 +1143,10 @@ void wxListMainWindow::DeleteLine( wxListLineData *line ) /* *** */ -void wxListMainWindow::Edit( long item ) +void wxListMainWindow::EditLabel( long item ) { wxNode *node = m_lines.Nth( item ); - wxCHECK_RET( node, "wrong index in wxListCtrl::Edit() "); + wxCHECK_RET( node, _T("wrong index in wxListCtrl::Edit()") ); m_currentEdit = (wxListLineData*) node->Data(); @@ -1152,7 +1156,8 @@ void wxListMainWindow::Edit( long item ) m_currentEdit->GetItem( 0, le.m_item ); GetParent()->GetEventHandler()->ProcessEvent( le ); - if (!le.IsAllowed()) return; + if (!le.IsAllowed()) + return; wxString s; m_currentEdit->GetText( 0, s ); @@ -1174,7 +1179,7 @@ void wxListMainWindow::Edit( long item ) void wxListMainWindow::OnRenameTimer() { - wxCHECK_RET( m_current, "invalid m_current" ); + wxCHECK_RET( m_current, _T("invalid m_current") ); Edit( m_lines.IndexOf( m_current ) ); } @@ -1190,7 +1195,11 @@ void wxListMainWindow::OnRenameAccept() if (!le.IsAllowed()) return; - /* DO CHANGE LABEL */ + wxListItem info; + info.m_mask = wxLIST_MASK_TEXT; + info.m_itemId = le.m_itemIndex; + info.m_text = m_renameRes; + SetItem( info ); } void wxListMainWindow::OnMouse( wxMouseEvent &event )