void OnRenameTimer();
bool OnRenameAccept(size_t itemEdit, const wxString& value);
+ void OnRenameCancelled(size_t itemEdit);
void OnMouse( wxMouseEvent &event );
case WXK_ESCAPE:
Finish();
+ m_owner->OnRenameCancelled( m_itemEdited );
break;
default:
{
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();
}
le.IsAllowed();
}
+void wxListMainWindow::OnRenameCancelled(size_t itemEdit)
+{
+ // wxMSW seems not to notify the program about
+ // cancelled label edits.
+ return;
+
+ // 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() );
le.m_item = (long) item;
le.SetEventObject( this );
le.m_label = wxEmptyString;
- le.m_editCancelled = FALSE;
+ le.m_editCancelled = TRUE;
GetEventHandler()->ProcessEvent( le );
}