diff --git a/include/wx/propgrid/props.h b/include/wx/propgrid/props.h index 406f9169a3..0e825af53f 100644 --- a/include/wx/propgrid/props.h +++ b/include/wx/propgrid/props.h @@ -968,6 +968,7 @@ public: void OnUpClick(wxCommandEvent& event); void OnDownClick(wxCommandEvent& event); void OnEndLabelEdit(wxListEvent& event); + void OnBeginLabelEdit(wxListEvent& evt); void OnIdle(wxIdleEvent& event); protected: diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 3f707f63d2..a334038736 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -2394,6 +2394,10 @@ bool wxPGArrayEditorDialog::Create( wxWindow *parent, wxCommandEventHandler(wxPGArrayEditorDialog::OnDownClick), NULL, this); + lc->Connect(lc->GetId(), wxEVT_LIST_BEGIN_LABEL_EDIT, + wxListEventHandler(wxPGArrayEditorDialog::OnBeginLabelEdit), + NULL, this); + lc->Connect(lc->GetId(), wxEVT_LIST_END_LABEL_EDIT, wxListEventHandler(wxPGArrayEditorDialog::OnEndLabelEdit), NULL, this); @@ -2462,8 +2466,6 @@ void wxPGArrayEditorDialog::OnAddClick(wxCommandEvent& event) } else { - m_itemPendingAtIndex = newItemIndex; - event.Skip(); } } @@ -2551,6 +2553,18 @@ void wxPGArrayEditorDialog::OnEndLabelEdit(wxListEvent& event) event.Skip(); } +void wxPGArrayEditorDialog::OnBeginLabelEdit(wxListEvent& evt) +{ + wxListCtrl* lc = m_elb->GetListCtrl(); + const int lastStringIndex = lc->GetItemCount() - 1; + const int curItemIndex = evt.GetIndex(); + // If current index is >= then last available index + // then we have a new pending element. + m_itemPendingAtIndex = curItemIndex < lastStringIndex? -1: curItemIndex; + + evt.Skip(); +} + #endif // wxUSE_EDITABLELISTBOX // -----------------------------------------------------------------------