Update to ending a label edit action in both tree control

and list controls. This includes the patch for tree
   control to correct the focus behavour when cancelling
   a label change action. It also adds an end_label_edit
   event to wxListCtrl when cancelling (this was not done
   before).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@21698 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2003-07-06 11:41:16 +00:00
parent 1d6e7c3803
commit 3a547e0e37
2 changed files with 41 additions and 14 deletions

View File

@@ -652,6 +652,7 @@ public:
void OnRenameTimer();
bool OnRenameAccept(size_t itemEdit, const wxString& value);
void OnRenameCancelled(size_t itemEdit);
void OnMouse( wxMouseEvent &event );
@@ -2302,6 +2303,7 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
case WXK_ESCAPE:
Finish();
m_owner->OnRenameCancelled( m_itemEdited );
break;
default:
@@ -2336,11 +2338,13 @@ void wxListTextCtrl::OnKillFocus( wxFocusEvent &event )
{
if ( !m_finished )
{
(void)AcceptChanges();
// We must finish regardless of success, otherwise we'll get focus problems
Finish();
if ( !AcceptChanges() )
m_owner->OnRenameCancelled( m_itemEdited );
}
event.Skip();
}
@@ -3072,6 +3076,11 @@ void wxListMainWindow::OnRenameTimer()
bool wxListMainWindow::OnRenameAccept(size_t itemEdit, const wxString& value)
{
wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() );
// These only exist for wxTreeCtrl, which should probably be changed
// le.m_editCancelled = FALSE;
// le.m_label = value;
le.SetEventObject( GetParent() );
le.m_itemIndex = itemEdit;
@@ -3080,10 +3089,31 @@ bool wxListMainWindow::OnRenameAccept(size_t itemEdit, const wxString& value)
data->GetItem( 0, le.m_item );
le.m_item.m_text = value;
return !GetParent()->GetEventHandler()->ProcessEvent( le ) ||
le.IsAllowed();
}
void wxListMainWindow::OnRenameCancelled(size_t itemEdit)
{
// let owner know that the edit was cancelled
wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() );
// These only exist for wxTreeCtrl, which should probably be changed
// le.m_editCancelled = TRUE;
// le.m_label = wxEmptyString;
le.SetEventObject( GetParent() );
le.m_itemIndex = itemEdit;
wxListLineData *data = GetLine(itemEdit);
wxCHECK_RET( data, _T("invalid index in OnRenameCancelled()") );
data->GetItem( 0, le.m_item );
GetEventHandler()->ProcessEvent( le );
}
void wxListMainWindow::OnMouse( wxMouseEvent &event )
{
event.SetEventObject( GetParent() );